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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
1.1 KiB
Python
Raw Normal View History

from __future__ import unicode_literals
import frappe
from frappe.utils import cint
def execute():
2018-09-11 11:20:46 +00:00
if not frappe.db.exists("DocType", "Time Log Batch"):
return
from erpnext.manufacturing.doctype.work_order.work_order import add_timesheet_detail
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):
2018-09-11 11:41:39 +00:00
from erpnext.patches.v7_0.convert_timelog_to_timesheet import get_timelog_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])