From 8448d9014d2e4177eaae87aae25d3f24f6d229c8 Mon Sep 17 00:00:00 2001 From: Zarrar Date: Sun, 9 Sep 2018 19:18:41 +0530 Subject: [PATCH] [Fix] Patch fixes (#15350) * fix typo in fieldname * fallback for work_order/production_order in timesheet --- .../v10_0/remove_and_copy_fields_in_physician.py | 2 +- erpnext/patches/v11_0/make_job_card.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/erpnext/patches/v10_0/remove_and_copy_fields_in_physician.py b/erpnext/patches/v10_0/remove_and_copy_fields_in_physician.py index f632c94239..07396711af 100644 --- a/erpnext/patches/v10_0/remove_and_copy_fields_in_physician.py +++ b/erpnext/patches/v10_0/remove_and_copy_fields_in_physician.py @@ -5,7 +5,7 @@ def execute(): frappe.reload_doc("healthcare", "doctype", "physician") frappe.reload_doc("healthcare", "doctype", "physician_service_unit_schedule") - if frappe.db.has_column('Physician', 'physician_schedule'): + if frappe.db.has_column('Physician', 'physician_schedules'): for doc in frappe.get_all('Physician'): _doc = frappe.get_doc('Physician', doc.name) if _doc.physician_schedule: diff --git a/erpnext/patches/v11_0/make_job_card.py b/erpnext/patches/v11_0/make_job_card.py index 4604889168..ad9a9af9ef 100644 --- a/erpnext/patches/v11_0/make_job_card.py +++ b/erpnext/patches/v11_0/make_job_card.py @@ -11,10 +11,16 @@ def execute(): frappe.reload_doc('manufacturing', 'doctype', 'job_card') frappe.reload_doc('manufacturing', 'doctype', 'job_card_item') - for d in frappe.db.sql("""select work_order, name from tabTimesheet - where (work_order is not null and work_order != '') and docstatus = 0""", as_dict=1): - if d.work_order: - doc = frappe.get_doc('Work Order', d.work_order) + fieldname = frappe.db.get_value('DocField', {'fieldname': 'work_order', 'parent': 'Timesheet'}, 'fieldname') + if not fieldname: + fieldname = frappe.db.get_value('DocField', {'fieldname': 'production_order', 'parent': 'Timesheet'}, 'fieldname') + if not fieldname: return + + for d in frappe.db.sql("""select %(fieldname)s, name from tabTimesheet + where (%(fieldname)s is not null and %(fieldname)s != '') and docstatus = 0""", + {'fieldname': fieldname}, as_dict=1): + if d[fieldname]: + doc = frappe.get_doc('Work Order', d[fieldname]) for row in doc.operations: create_job_card(doc, row, auto_create=True) - frappe.delete_doc('Timesheet', d.name) \ No newline at end of file + frappe.delete_doc('Timesheet', d.name)