2016-06-03 09:14:35 +00:00
|
|
|
import frappe
|
|
|
|
|
2016-07-11 08:54:52 +00:00
|
|
|
from erpnext.manufacturing.doctype.production_order.production_order import make_timesheet, add_timesheet_detail
|
2016-06-03 09:14:35 +00:00
|
|
|
|
2016-06-29 10:02:36 +00:00
|
|
|
def execute():
|
2016-07-14 09:02:15 +00:00
|
|
|
frappe.reload_doc('projects', 'doctype', 'timesheet')
|
2016-07-12 20:20:32 +00:00
|
|
|
|
2016-06-03 09:14:35 +00:00
|
|
|
for data in frappe.get_all('Time Log', fields=["*"],
|
|
|
|
filters = [["docstatus", "<", "2"]]):
|
2016-07-11 08:54:52 +00:00
|
|
|
time_sheet = make_timesheet(data.production_order)
|
2016-07-12 20:20:32 +00:00
|
|
|
args = get_timelog_data(data)
|
2016-06-03 09:14:35 +00:00
|
|
|
add_timesheet_detail(time_sheet, args)
|
|
|
|
time_sheet.docstatus = data.docstatus
|
2016-07-12 20:20:32 +00:00
|
|
|
time_sheet.note = data.note
|
2016-06-03 09:14:35 +00:00
|
|
|
time_sheet.company = frappe.db.get_single_value('Global Defaults', 'default_company')
|
|
|
|
time_sheet.save(ignore_permissions=True)
|
|
|
|
|
2016-07-12 20:20:32 +00:00
|
|
|
def get_timelog_data(data):
|
2016-06-03 09:14:35 +00:00
|
|
|
return {
|
2016-07-02 14:42:34 +00:00
|
|
|
'billable': data.billable,
|
2016-06-03 09:14:35 +00:00
|
|
|
'from_time': data.from_time,
|
|
|
|
'hours': data.hours,
|
|
|
|
'to_time': data.to_time,
|
|
|
|
'project': data.project,
|
2016-07-02 14:42:34 +00:00
|
|
|
'task': data.task,
|
2016-06-29 10:02:36 +00:00
|
|
|
'activity_type': data.activity_type,
|
2016-06-03 09:14:35 +00:00
|
|
|
'operation': data.operation,
|
|
|
|
'operation_id': data.operation_id,
|
|
|
|
'workstation': data.workstation,
|
2016-07-12 20:20:32 +00:00
|
|
|
'completed_qty': data.completed_qty,
|
|
|
|
'billing_rate': data.billing_rate,
|
|
|
|
'billing_amount': data.billing_amount,
|
|
|
|
'costing_rate': data.costing_rate,
|
|
|
|
'costing_amount': data.costing_amount
|
2016-06-29 10:02:36 +00:00
|
|
|
}
|