fix(Healthcare): remove hardcoded UOM during Item creation for Templates (#21350)

This commit is contained in:
Rucha Mahabal 2020-04-21 12:54:07 +05:30 committed by GitHub
parent 9ea1ad4051
commit ca1c37c56d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 18 deletions

View File

@ -79,6 +79,7 @@ def create_item_from_template(doc):
if doc.is_billable and not doc.disabled: if doc.is_billable and not doc.disabled:
disabled = 0 disabled = 0
uom = frappe.db.exists('UOM', 'Unit') or frappe.db.get_single_value('Stock Settings', 'stock_uom')
item = frappe.get_doc({ item = frappe.get_doc({
'doctype': 'Item', 'doctype': 'Item',
'item_code': doc.template, 'item_code': doc.template,
@ -92,7 +93,7 @@ def create_item_from_template(doc):
'show_in_website': 0, 'show_in_website': 0,
'is_pro_applicable': 0, 'is_pro_applicable': 0,
'disabled': disabled, 'disabled': disabled,
'stock_uom': 'Unit' 'stock_uom': uom
}).insert(ignore_permissions=True, ignore_mandatory=True) }).insert(ignore_permissions=True, ignore_mandatory=True)
make_item_price(item.name, doc.rate) make_item_price(item.name, doc.rate)

View File

@ -74,10 +74,11 @@ class LabTestTemplate(Document):
def create_item_from_template(doc): def create_item_from_template(doc):
if doc.is_billable: disabled = doc.disabled
if doc.is_billable and not doc.disabled:
disabled = 0 disabled = 0
else:
disabled = 1 uom = frappe.db.exists('UOM', 'Unit') or frappe.db.get_single_value('Stock Settings', 'stock_uom')
# insert item # insert item
item = frappe.get_doc({ item = frappe.get_doc({
"doctype": "Item", "doctype": "Item",
@ -92,8 +93,8 @@ def create_item_from_template(doc):
"show_in_website": 0, "show_in_website": 0,
"is_pro_applicable": 0, "is_pro_applicable": 0,
"disabled": disabled, "disabled": disabled,
"stock_uom": "Unit" "stock_uom": uom
}).insert(ignore_permissions=True) }).insert(ignore_permissions=True, ignore_mandatory=True)
# insert item price # insert item price
# get item price list to insert item price # get item price list to insert item price