From b60979cfaacdcede5b58f830868fc1b5d7653818 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 25 Mar 2020 02:10:33 +0530 Subject: [PATCH] fix: show Change Item Code button only if Unit Type is billable --- .../healthcare_practitioner.json | 10 +++++----- .../healthcare_service_unit_type.js | 5 +++-- erpnext/healthcare/doctype/patient/patient.py | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json index 67712c90654..9860a21ea74 100644 --- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json +++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json @@ -38,13 +38,13 @@ "column_break_18", "inpatient_visit_charge_item", "inpatient_visit_charge", + "account_details", + "default_currency", + "accounts", "address_and_contacts_section", "address_html", "column_break_19", - "contact_html", - "account_details", - "accounts", - "default_currency" + "contact_html" ], "fields": [ { @@ -277,7 +277,7 @@ ], "image_field": "image", "links": [], - "modified": "2020-03-20 15:13:13.382212", + "modified": "2020-03-24 17:25:55.128808", "modified_by": "Administrator", "module": "Healthcare", "name": "Healthcare Practitioner", diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js index f5e8a6f2de8..eb33ab68c0d 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js +++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js @@ -4,7 +4,7 @@ frappe.ui.form.on('Healthcare Service Unit Type', { refresh: function(frm) { 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() { change_item_code(cur_frm, frm.doc); }); @@ -59,7 +59,8 @@ let change_item_code = function(frm, doc) { 'fieldtype': 'Data', 'label': 'Item Code', 'fieldname': 'item_code', - reqd: 1 + 'default': doc.item_code, + reqd: 1, } ], primary_action: function() { diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py index d03a13162eb..fc63b19976a 100644 --- a/erpnext/healthcare/doctype/patient/patient.py +++ b/erpnext/healthcare/doctype/patient/patient.py @@ -53,6 +53,7 @@ class Patient(Document): set_name_by_naming_series(self) def get_patient_name(self): + self.set_full_name() name = self.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