feat: additional customer fileds

add customer_group, price list, currency etc.
rearrange and group fields
disable cusotmer edit after save (temp fix)
This commit is contained in:
anoop 2020-04-13 11:36:06 +05:30
parent 17ab1592c7
commit d4f5a6928f
3 changed files with 65 additions and 27 deletions

View File

@ -40,6 +40,7 @@ frappe.ui.form.on('Patient', {
frm.add_custom_button(__('Patient Encounter'), function () { frm.add_custom_button(__('Patient Encounter'), function () {
create_encounter(frm); create_encounter(frm);
}, 'Create'); }, 'Create');
frm.toggle_enable(['customer'], 0); // ToDo, allow change only if no transactions booked or better, add merge option
} }
}, },
onload: function (frm) { onload: function (frm) {

View File

@ -24,13 +24,20 @@
"image", "image",
"column_break_14", "column_break_14",
"status", "status",
"inpatient_status",
"inpatient_record", "inpatient_record",
"customer", "inpatient_status",
"report_preference",
"mobile", "mobile",
"email", "email",
"phone", "phone",
"report_preference", "customer_details_section",
"customer",
"customer_group",
"territory",
"column_break_24",
"default_currency",
"default_price_list",
"language",
"personal_and_social_history", "personal_and_social_history",
"occupation", "occupation",
"column_break_25", "column_break_25",
@ -52,9 +59,7 @@
"surrounding_factors", "surrounding_factors",
"other_risk_factors", "other_risk_factors",
"more_info", "more_info",
"patient_details", "patient_details"
"ac_sb",
"default_currency"
], ],
"fields": [ "fields": [
{ {
@ -156,6 +161,7 @@
"fieldname": "customer", "fieldname": "customer",
"fieldtype": "Link", "fieldtype": "Link",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"in_preview": 1,
"label": "Customer", "label": "Customer",
"options": "Customer" "options": "Customer"
}, },
@ -171,7 +177,8 @@
"fieldtype": "Data", "fieldtype": "Data",
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Mobile" "label": "Mobile",
"options": "Phone"
}, },
{ {
"bold": 1, "bold": 1,
@ -186,7 +193,8 @@
"fieldname": "phone", "fieldname": "phone",
"fieldtype": "Data", "fieldtype": "Data",
"in_filter": 1, "in_filter": 1,
"label": "Phone" "label": "Phone",
"options": "Phone"
}, },
{ {
"collapsible": 1, "collapsible": 1,
@ -268,25 +276,25 @@
"fieldname": "tobacco_past_use", "fieldname": "tobacco_past_use",
"fieldtype": "Data", "fieldtype": "Data",
"ignore_xss_filter": 1, "ignore_xss_filter": 1,
"label": "Tobacco Consumption Habbits (Past)" "label": "Tobacco Consumption (Past)"
}, },
{ {
"fieldname": "tobacco_current_use", "fieldname": "tobacco_current_use",
"fieldtype": "Data", "fieldtype": "Data",
"ignore_xss_filter": 1, "ignore_xss_filter": 1,
"label": "Tobacco Consumption Habbits (Present)" "label": "Tobacco Consumption (Present)"
}, },
{ {
"fieldname": "alcohol_past_use", "fieldname": "alcohol_past_use",
"fieldtype": "Data", "fieldtype": "Data",
"ignore_xss_filter": 1, "ignore_xss_filter": 1,
"label": "Alcohol Consumption Habbits (Past)" "label": "Alcohol Consumption (Past)"
}, },
{ {
"fieldname": "alcohol_current_use", "fieldname": "alcohol_current_use",
"fieldtype": "Data", "fieldtype": "Data",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"label": "Alcohol Consumption Habbits (Present)" "label": "Alcohol Consumption (Present)"
}, },
{ {
"fieldname": "column_break_32", "fieldname": "column_break_32",
@ -320,20 +328,11 @@
"ignore_xss_filter": 1, "ignore_xss_filter": 1,
"label": "Patient Details" "label": "Patient Details"
}, },
{
"collapsible": 1,
"fieldname": "ac_sb",
"fieldtype": "Section Break",
"label": "Account Details"
},
{ {
"fieldname": "default_currency", "fieldname": "default_currency",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "label": "Billing Currency",
"ignore_xss_filter": 1, "options": "Currency"
"label": "Default Currency",
"options": "Currency",
"print_hide": 1
}, },
{ {
"fieldname": "last_name", "fieldname": "last_name",
@ -351,13 +350,47 @@
"fieldname": "middle_name", "fieldname": "middle_name",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Middle Name (optional)" "label": "Middle Name (optional)"
},
{
"collapsible": 1,
"fieldname": "customer_details_section",
"fieldtype": "Section Break",
"label": "Customer Details"
},
{
"fieldname": "customer_group",
"fieldtype": "Link",
"label": "Customer Group",
"options": "Customer Group"
},
{
"fieldname": "territory",
"fieldtype": "Link",
"label": "Territory",
"options": "Territory"
},
{
"fieldname": "column_break_24",
"fieldtype": "Column Break"
},
{
"fieldname": "default_price_list",
"fieldtype": "Link",
"label": "Default Price List",
"options": "Price List"
},
{
"fieldname": "language",
"fieldtype": "Link",
"label": "Print Language",
"options": "Language"
} }
], ],
"icon": "fa fa-user", "icon": "fa fa-user",
"image_field": "image", "image_field": "image",
"links": [], "links": [],
"max_attachments": 50, "max_attachments": 50,
"modified": "2020-04-06 12:55:30.807744", "modified": "2020-04-11 14:53:48.767245",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Healthcare", "module": "Healthcare",
"name": "Patient", "name": "Patient",

View File

@ -26,6 +26,7 @@ class Patient(Document):
frappe.db.set_value('Patient', self.name, 'status', 'Disabled') frappe.db.set_value('Patient', self.name, 'status', 'Disabled')
else: else:
send_registration_sms(self) send_registration_sms(self)
self.reload() # self.notify_update()
def set_full_name(self): def set_full_name(self):
if self.last_name: if self.last_name:
@ -86,8 +87,8 @@ class Patient(Document):
return {'invoice': sales_invoice.name} return {'invoice': sales_invoice.name}
def create_customer(doc): def create_customer(doc):
customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group') customer_group = doc.customer_group or frappe.db.get_single_value('Selling Settings', 'customer_group')
territory = frappe.db.get_single_value('Selling Settings', 'territory') territory = doc.territory or frappe.db.get_single_value('Selling Settings', 'territory')
if not (customer_group and territory): if not (customer_group and territory):
customer_group = get_root_of('Customer Group') customer_group = get_root_of('Customer Group')
territory = get_root_of('Territory') territory = get_root_of('Territory')
@ -98,7 +99,10 @@ def create_customer(doc):
'customer_name': doc.patient_name, 'customer_name': doc.patient_name,
'customer_group': customer_group, 'customer_group': customer_group,
'territory' : territory, 'territory' : territory,
'customer_type': 'Individual' 'customer_type': 'Individual',
'default_currency': doc.default_currency,
'default_price_ist': doc.default_price_list,
'language': doc.language
}).insert(ignore_permissions=True, ignore_mandatory=True) }).insert(ignore_permissions=True, ignore_mandatory=True)
frappe.db.set_value('Patient', doc.name, 'customer', customer.name) frappe.db.set_value('Patient', doc.name, 'customer', customer.name)