fix: show Change Item Code button only if Unit Type is billable

This commit is contained in:
Rucha Mahabal 2020-03-25 02:10:33 +05:30
parent 1900a62c54
commit b60979cfaa
3 changed files with 9 additions and 7 deletions

View File

@ -38,13 +38,13 @@
"column_break_18", "column_break_18",
"inpatient_visit_charge_item", "inpatient_visit_charge_item",
"inpatient_visit_charge", "inpatient_visit_charge",
"account_details",
"default_currency",
"accounts",
"address_and_contacts_section", "address_and_contacts_section",
"address_html", "address_html",
"column_break_19", "column_break_19",
"contact_html", "contact_html"
"account_details",
"accounts",
"default_currency"
], ],
"fields": [ "fields": [
{ {
@ -277,7 +277,7 @@
], ],
"image_field": "image", "image_field": "image",
"links": [], "links": [],
"modified": "2020-03-20 15:13:13.382212", "modified": "2020-03-24 17:25:55.128808",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Healthcare", "module": "Healthcare",
"name": "Healthcare Practitioner", "name": "Healthcare Practitioner",

View File

@ -4,7 +4,7 @@
frappe.ui.form.on('Healthcare Service Unit Type', { frappe.ui.form.on('Healthcare Service Unit Type', {
refresh: function(frm) { refresh: function(frm) {
frm.set_df_property('item_code', 'read_only', frm.doc.__islocal ? 0 : 1); frm.set_df_property('item_code', 'read_only', frm.doc.__islocal ? 0 : 1);
if (!frm.doc.__islocal) { if (!frm.doc.__islocal && frm.doc.is_billable) {
frm.add_custom_button(__('Change Item Code'), function() { frm.add_custom_button(__('Change Item Code'), function() {
change_item_code(cur_frm, frm.doc); change_item_code(cur_frm, frm.doc);
}); });
@ -59,7 +59,8 @@ let change_item_code = function(frm, doc) {
'fieldtype': 'Data', 'fieldtype': 'Data',
'label': 'Item Code', 'label': 'Item Code',
'fieldname': 'item_code', 'fieldname': 'item_code',
reqd: 1 'default': doc.item_code,
reqd: 1,
} }
], ],
primary_action: function() { primary_action: function() {

View File

@ -53,6 +53,7 @@ class Patient(Document):
set_name_by_naming_series(self) set_name_by_naming_series(self)
def get_patient_name(self): def get_patient_name(self):
self.set_full_name()
name = self.patient_name name = self.patient_name
if frappe.db.get_value('Patient', name): if frappe.db.get_value('Patient', name):
count = frappe.db.sql("""select ifnull(MAX(CAST(SUBSTRING_INDEX(name, ' ', -1) AS UNSIGNED)), 0) from tabPatient count = frappe.db.sql("""select ifnull(MAX(CAST(SUBSTRING_INDEX(name, ' ', -1) AS UNSIGNED)), 0) from tabPatient