chore: Lab Test Template form clean-up
diff --git a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.json b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.json
index db64297..fc6a1e1 100644
--- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.json
+++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.json
@@ -112,7 +112,7 @@
{
"default": "1",
"depends_on": "eval:doc.lab_test_template_type != 'Grouped'",
- "description": "If unchecked, the item wont be appear in Sales Invoice, but can be used in group test creation. ",
+ "description": "If unchecked, the item will not be available in Sales Invoices for billing but can be used in group test creation. ",
"fieldname": "is_billable",
"fieldtype": "Check",
"label": "Is Billable",
@@ -184,7 +184,7 @@
"depends_on": "eval:doc.lab_test_template_type == 'Descriptive'",
"fieldname": "section_break_special",
"fieldtype": "Section Break",
- "label": "Descriptive"
+ "label": "Descriptive Test"
},
{
"default": "0",
@@ -196,7 +196,7 @@
"depends_on": "eval:doc.lab_test_template_type == 'Grouped'",
"fieldname": "section_break_group",
"fieldtype": "Section Break",
- "label": "Group"
+ "label": "Group Tests"
},
{
"fieldname": "lab_test_groups",
@@ -314,7 +314,7 @@
}
],
"links": [],
- "modified": "2020-07-13 12:57:09.925436",
+ "modified": "2020-07-30 11:55:43.093828",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Test Template",
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 6f0d08c..e4fbdd9 100644
--- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py
+++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py
@@ -15,7 +15,8 @@
def validate(self):
if self.is_billable and (not self.lab_test_rate or self.lab_test_rate <= 0.0):
- frappe.throw(_("Standard Selling Rate should be greater than zero."))
+ frappe.throw(_('Standard Selling Rate should be greater than zero.'))
+
self.validate_conversion_factor()
self.enable_disable_item()
@@ -42,7 +43,9 @@
# Remove template reference from item and disable item
if self.item:
try:
- frappe.delete_doc('Item', self.item)
+ item = self.item
+ self.db_set('item', '')
+ frappe.delete_doc('Item', item)
except Exception:
frappe.throw(_('Not permitted. Please disable the Lab Test Template'))
@@ -63,26 +66,26 @@
'standard_rate': self.lab_test_rate,
'description': self.lab_test_description
})
- item.save()
+ item.flags.ignore_mandatory = True
+ item.save(ignore_permissions=True)
def item_price_exists(self):
item_price = frappe.db.exists({'doctype': 'Item Price', 'item_code': self.lab_test_code})
if item_price:
return item_price[0][0]
- else:
- return False
+ return False
def validate_conversion_factor(self):
- if self.lab_test_template_type == "Single" and self.secondary_uom and not self.conversion_factor:
- frappe.throw(_("Conversion Factor is mandatory"))
- if self.lab_test_template_type == "Compound":
+ if self.lab_test_template_type == 'Single' and self.secondary_uom and not self.conversion_factor:
+ frappe.throw(_('Conversion Factor is mandatory'))
+ if self.lab_test_template_type == 'Compound':
for item in self.normal_test_templates:
if item.secondary_uom and not item.conversion_factor:
- frappe.throw(_("Conversion Factor is mandatory"))
- if self.lab_test_template_type == "Grouped":
+ frappe.throw(_('Conversion Factor is mandatory'))
+ if self.lab_test_template_type == 'Grouped':
for group in self.lab_test_groups:
- if group.template_or_new_line == "Add New Line" and group.secondary_uom and not group.conversion_factor:
- frappe.throw(_("Conversion Factor is mandatory"))
+ if group.template_or_new_line == 'Add New Line' and group.secondary_uom and not group.conversion_factor:
+ frappe.throw(_('Conversion Factor is mandatory'))
def create_item_from_template(doc):
@@ -101,9 +104,9 @@
'include_item_in_manufacturing': 0,
'show_in_website': 0,
'is_pro_applicable': 0,
- 'disabled': 0 if doc.is_billable and not doc.disabled else doc.disabled,
+ 'disabled': 0 if doc.is_billable and not doc.disabled else doc.disabled,
'stock_uom': uom
- }).insert(ignore_permissions = True, ignore_mandatory = True)
+ }).insert(ignore_permissions=True, ignore_mandatory=True)
# Insert item price
if doc.is_billable and doc.lab_test_rate != 0.0:
@@ -123,7 +126,7 @@
'price_list': price_list_name,
'item_code': item,
'price_list_rate': item_price
- }).insert(ignore_permissions = True, ignore_mandatory = True)
+ }).insert(ignore_permissions=True, ignore_mandatory=True)
@frappe.whitelist()
def change_test_code_from_template(lab_test_code, doc):
@@ -132,8 +135,8 @@
if frappe.db.exists({'doctype': 'Item', 'item_code': lab_test_code}):
frappe.throw(_('Lab Test Item {0} already exist').format(lab_test_code))
else:
- rename_doc('Item', doc.name, lab_test_code, ignore_permissions = True)
+ rename_doc('Item', doc.name, lab_test_code, ignore_permissions=True)
frappe.db.set_value('Lab Test Template', doc.name, 'lab_test_code', lab_test_code)
frappe.db.set_value('Lab Test Template', doc.name, 'lab_test_name', lab_test_code)
- rename_doc('Lab Test Template', doc.name, lab_test_code, ignore_permissions = True)
+ rename_doc('Lab Test Template', doc.name, lab_test_code, ignore_permissions=True)
return lab_test_code
diff --git a/erpnext/healthcare/doctype/lab_test_template/lab_test_template_list.js b/erpnext/healthcare/doctype/lab_test_template/lab_test_template_list.js
index a3417eb..08fc2cd 100644
--- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template_list.js
+++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template_list.js
@@ -3,5 +3,5 @@
*/
frappe.listview_settings['Lab Test Template'] = {
add_fields: ['lab_test_name', 'lab_test_code', 'lab_test_rate'],
- filters: [['disabled', '=', 0]]
+ filters: [['disabled', '=', 'No']]
};