2016-06-03 14:44:35 +05:30
|
|
|
import frappe
|
|
|
|
from frappe.utils import cint
|
2018-03-20 12:38:43 +05:30
|
|
|
from erpnext.manufacturing.doctype.work_order.work_order import add_timesheet_detail
|
2016-07-13 01:50:32 +05:30
|
|
|
from erpnext.patches.v7_0.convert_timelog_to_timesheet import get_timelog_data
|
2016-06-03 14:44:35 +05:30
|
|
|
|
2016-07-13 01:50:32 +05:30
|
|
|
def execute():
|
2016-06-03 14:44:35 +05:30
|
|
|
for tlb in frappe.get_all('Time Log Batch', fields=["*"],
|
|
|
|
filters = [["docstatus", "<", "2"]]):
|
2016-07-06 20:12:58 +05:30
|
|
|
time_sheet = frappe.new_doc('Timesheet')
|
2016-06-03 14:44:35 +05:30
|
|
|
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 13:21:54 +05:30
|
|
|
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 11:08:02 +05:30
|
|
|
time_sheet.flags.ignore_links = True
|
2016-07-04 13:21:54 +05:30
|
|
|
time_sheet.save(ignore_permissions=True)
|
2016-06-03 14:44:35 +05:30
|
|
|
|
|
|
|
def get_timesheet_data(data):
|
2016-09-23 11:08:02 +05:30
|
|
|
time_log = frappe.get_all('Time Log', fields=["*"], filters = {'name': data.time_log})
|
|
|
|
if time_log:
|
|
|
|
return get_timelog_data(time_log[0])
|