fix: update linked Customer on Patient update only if Link Customer to Patient is enabled (#25921)

This commit is contained in:
Anoop 2021-06-03 09:24:31 +05:30 committed by GitHub
parent 811f607c85
commit f899b3a633
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,21 +33,20 @@ class Patient(Document):
self.reload() # self.notify_update()
def on_update(self):
if self.customer:
customer = frappe.get_doc('Customer', self.customer)
if self.customer_group:
customer.customer_group = self.customer_group
if self.territory:
customer.territory = self.territory
customer.customer_name = self.patient_name
customer.default_price_list = self.default_price_list
customer.default_currency = self.default_currency
customer.language = self.language
customer.ignore_mandatory = True
customer.save(ignore_permissions=True)
else:
if frappe.db.get_single_value('Healthcare Settings', 'link_customer_to_patient'):
if frappe.db.get_single_value('Healthcare Settings', 'link_customer_to_patient'):
if self.customer:
customer = frappe.get_doc('Customer', self.customer)
if self.customer_group:
customer.customer_group = self.customer_group
if self.territory:
customer.territory = self.territory
customer.customer_name = self.patient_name
customer.default_price_list = self.default_price_list
customer.default_currency = self.default_currency
customer.language = self.language
customer.ignore_mandatory = True
customer.save(ignore_permissions=True)
else:
create_customer(self)
def set_full_name(self):