From ca1c37c56d2700254992e7f9da78be0a3e9fabde Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 21 Apr 2020 12:54:07 +0530 Subject: [PATCH] fix(Healthcare): remove hardcoded UOM during Item creation for Templates (#21350) --- .../clinical_procedure_template.py | 3 +- .../lab_test_template/lab_test_template.py | 35 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py index 3f295afc3e..f32b7cf9d8 100644 --- a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py +++ b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py @@ -79,6 +79,7 @@ def create_item_from_template(doc): if doc.is_billable and not doc.disabled: disabled = 0 + uom = frappe.db.exists('UOM', 'Unit') or frappe.db.get_single_value('Stock Settings', 'stock_uom') item = frappe.get_doc({ 'doctype': 'Item', 'item_code': doc.template, @@ -92,7 +93,7 @@ def create_item_from_template(doc): 'show_in_website': 0, 'is_pro_applicable': 0, 'disabled': disabled, - 'stock_uom': 'Unit' + 'stock_uom': uom }).insert(ignore_permissions=True, ignore_mandatory=True) make_item_price(item.name, doc.rate) diff --git a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py index 6bbb4f1c3a..e2b47b4559 100644 --- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py +++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py @@ -74,26 +74,27 @@ class LabTestTemplate(Document): def create_item_from_template(doc): - if doc.is_billable: + disabled = doc.disabled + if doc.is_billable and not doc.disabled: disabled = 0 - else: - disabled = 1 + + uom = frappe.db.exists('UOM', 'Unit') or frappe.db.get_single_value('Stock Settings', 'stock_uom') # insert item item = frappe.get_doc({ - "doctype": "Item", - "item_code": doc.lab_test_code, - "item_name":doc.lab_test_name, - "item_group": doc.lab_test_group, - "description":doc.lab_test_description, - "is_sales_item": 1, - "is_service_item": 1, - "is_purchase_item": 0, - "is_stock_item": 0, - "show_in_website": 0, - "is_pro_applicable": 0, - "disabled": disabled, - "stock_uom": "Unit" - }).insert(ignore_permissions=True) + "doctype": "Item", + "item_code": doc.lab_test_code, + "item_name":doc.lab_test_name, + "item_group": doc.lab_test_group, + "description":doc.lab_test_description, + "is_sales_item": 1, + "is_service_item": 1, + "is_purchase_item": 0, + "is_stock_item": 0, + "show_in_website": 0, + "is_pro_applicable": 0, + "disabled": disabled, + "stock_uom": uom + }).insert(ignore_permissions=True, ignore_mandatory=True) # insert item price # get item price list to insert item price