brotherton-erpnext/erpnext/patches/v7_0/convert_timelogbatch_to_timesheet.py

26 lines
1003 B
Python
Raw Normal View History

import frappe
from frappe.utils import cint
from erpnext.manufacturing.doctype.work_order.work_order import add_timesheet_detail
from erpnext.patches.v7_0.convert_timelog_to_timesheet import get_timelog_data
def execute():
for tlb in frappe.get_all('Time Log Batch', fields=["*"],
filters = [["docstatus", "<", "2"]]):
2016-07-06 14:42:58 +00:00
time_sheet = frappe.new_doc('Timesheet')
time_sheet.employee= ""
time_sheet.company = frappe.db.get_single_value('Global Defaults', 'default_company')
time_sheet.sales_invoice = tlb.sales_invoice
2016-07-04 07:51:54 +00:00
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
2016-09-23 05:38:02 +00:00
time_sheet.flags.ignore_links = True
2016-07-04 07:51:54 +00:00
time_sheet.save(ignore_permissions=True)
def get_timesheet_data(data):
2016-09-23 05:38:02 +00:00
time_log = frappe.get_all('Time Log', fields=["*"], filters = {'name': data.time_log})
if time_log:
return get_timelog_data(time_log[0])