2016-06-03 09:14:35 +00:00
|
|
|
import frappe
|
|
|
|
from frappe.utils import cint
|
|
|
|
from erpnext.manufacturing.doctype.production_order.production_order import add_timesheet_detail
|
2016-07-12 20:20:32 +00:00
|
|
|
from erpnext.patches.v7_0.convert_timelog_to_timesheet import get_timelog_data
|
2016-06-03 09:14:35 +00:00
|
|
|
|
2016-07-12 20:20:32 +00:00
|
|
|
def execute():
|
2016-06-03 09:14:35 +00:00
|
|
|
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')
|
2016-06-03 09:14:35 +00:00
|
|
|
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)
|
2016-06-03 09:14:35 +00:00
|
|
|
|
|
|
|
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])
|