[Fixes] Time log batch patch
This commit is contained in:
parent
c1d2247f2c
commit
240407b155
@ -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,
|
||||
|
@ -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()
|
@ -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")
|
Loading…
Reference in New Issue
Block a user