diff --git a/erpnext/patches/v7_0/convert_timelogbatch_to_timesheet.py b/erpnext/patches/v7_0/convert_timelogbatch_to_timesheet.py index 6a50aa2aeb..252b820480 100644 --- a/erpnext/patches/v7_0/convert_timelogbatch_to_timesheet.py +++ b/erpnext/patches/v7_0/convert_timelogbatch_to_timesheet.py @@ -9,16 +9,18 @@ def execute(): time_sheet.employee= "" time_sheet.company = frappe.db.get_single_value('Global Defaults', 'default_company') time_sheet.sales_invoice = tlb.sales_invoice - if tlb.get('time_logs'): - for data in tlb.time_logs: - args = get_timesheet_data(data) - add_timesheet_detail(time_sheet, args) - time_sheet.docstatus = tlb.docstatus - time_sheet.save(ignore_permissions=True) + for data in frappe.get_all('Time Log Batch Detail', fields=["*"], + filters = {'parent': tlb.name}): + args = get_timesheet_data(data) + add_timesheet_detail(time_sheet, args) + + time_sheet.docstatus = tlb.docstatus + time_sheet.save(ignore_permissions=True) def get_timesheet_data(data): - time_log = frappe.get_doc('Time Log', data.time_log) + time_log = frappe.get_all('Time Log', fields=["*"], + filters = {'name': data.time_log})[0] return { 'billable': time_log.billable, diff --git a/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py b/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py index 55b51b7a59..e994199c69 100644 --- a/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py +++ b/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py @@ -1,16 +1,12 @@ import frappe -from erpnext.manufacturing.doctype.production_order.production_order import add_timesheet_detail - def execute(): - for si in frappe.db.sql(""" select sales_invoice as name from `tabTime Sheet` + for time_sheet in frappe.db.sql(""" select sales_invoice, name, total_billing_amount from `tabTime Sheet` where sales_invoice is not null and docstatus < 2""", as_dict=True): - si_doc = frappe.get_doc('Sales Invoice', si.name) - for item in si_doc.items: - if item.time_log_batch: - ts = si_doc.append('timesheets',{}) - ts.time_sheet = item.time_log_batch - ts.billing_amount = frappe.db.get_value('Time Log Batch', item.time_log_batch, 'total_billing_amount') - si_doc.ignore_validate_update_after_submit = True - si_doc.update_time_sheet(ts.time_sheet) + si_doc = frappe.get_doc('Sales Invoice', time_sheet.sales_invoice) + ts = si_doc.append('timesheets',{}) + ts.time_sheet = time_sheet.name + ts.billing_amount = time_sheet.total_billing_amount + si_doc.update_time_sheet(time_sheet.sales_invoice) + si_doc.flags.ignore_validate_update_after_submit = True si_doc.save() \ No newline at end of file diff --git a/erpnext/patches/v7_0/set_naming_series_for_timesheet.py b/erpnext/patches/v7_0/set_naming_series_for_timesheet.py index a0522828c5..7c26e59ebf 100644 --- a/erpnext/patches/v7_0/set_naming_series_for_timesheet.py +++ b/erpnext/patches/v7_0/set_naming_series_for_timesheet.py @@ -9,6 +9,7 @@ from frappe.custom.doctype.property_setter.property_setter import make_property_ def execute(): frappe.reload_doc('projects', 'doctype','time_sheet') frappe.reload_doc('projects', 'doctype', 'time_sheet_detail') + frappe.reload_doc('accounts', 'doctype', 'sales_invoice_timesheet') make_property_setter('Time Sheet', "naming_series", "options", 'TS-', "Text") make_property_setter('Time Sheet', "naming_series", "default", 'TS-', "Text") \ No newline at end of file