chore: Lab Test Template form clean-up

This commit is contained in:
Rucha Mahabal 2020-07-30 12:16:18 +05:30
parent 9e81bb9a11
commit 440c752529
3 changed files with 25 additions and 22 deletions

View File

@ -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",

View File

@ -15,7 +15,8 @@ class LabTestTemplate(Document):
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 @@ class LabTestTemplate(Document):
# 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 @@ class LabTestTemplate(Document):
'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
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):

View File

@ -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']]
};