[Fix] Patch fixes (#15350)
* fix typo in fieldname
* fallback for work_order/production_order in timesheet
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 f632c94..0739671 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 @@
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 4604889..ad9a9af 100644
--- a/erpnext/patches/v11_0/make_job_card.py
+++ b/erpnext/patches/v11_0/make_job_card.py
@@ -11,10 +11,16 @@
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)