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

26 lines
964 B
Python
Raw Normal View History

import frappe
from frappe.utils import cint
from erpnext.manufacturing.doctype.production_order.production_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
time_sheet.save(ignore_permissions=True)
def get_timesheet_data(data):
2016-07-04 07:51:54 +00:00
time_log = frappe.get_all('Time Log', fields=["*"],
filters = {'name': data.time_log})[0]
return get_timelog_data(time_log)