diff --git a/erpnext/accounts/custom/address.py b/erpnext/accounts/custom/address.py index 184a979e0804bac8f762591b2f4e3bdf9f9cd28f..5ea8b1d1ca887a7d2221182928a756f133bf2008 100644 --- a/erpnext/accounts/custom/address.py +++ b/erpnext/accounts/custom/address.py @@ -11,17 +11,9 @@ class ERPNextAddress(Address): def validate(self): self.validate_reference() self.update_company_address() - super().validate() - def on_update(self): - """ - After Address is updated, update the related 'Primary Address' on Customer. - """ - address_display = get_address_display(self.as_dict()) - filters = {"customer_primary_address": self.name} - customers = frappe.db.get_all("Customer", filters=filters, as_list=True) - for customer_name in customers: - frappe.db.set_value("Customer", customer_name[0], "primary_address", address_display) + if hasattr(super(), "validate"): + super().validate() def link_address(self): """Link address based on owner""" @@ -44,6 +36,20 @@ class ERPNextAddress(Address): title=_("Company Not Linked"), ) + def on_update(self): + """ + After Address is updated, update the related 'Primary Address' on Customer. + """ + + if hasattr(super(), "on_update"): + super().on_update() + + address_display = get_address_display(self.as_dict()) + filters = {"customer_primary_address": self.name} + customers = frappe.db.get_all("Customer", filters=filters, as_list=True) + for customer_name in customers: + frappe.db.set_value("Customer", customer_name[0], "primary_address", address_display) + @frappe.whitelist() def get_shipping_address(company, address=None): diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 0d6bd7da52b24d7900c0c934cc52b4e7258150cb..36c0aa718df26e3cb05282e71a8a0a72502355bf 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -158,10 +158,7 @@ doctype_list_js = { doctype_css = { "Event": "public/css/event.css", } - -override_doctype_class = { - "Address": "erpnext.accounts.custom.address.ERPNextAddress", -} +extend_doctype_class = {"Address": "erpnext.accounts.custom.address.ERPNextAddress"} override_whitelisted_methods = {"frappe.www.contact.send_message": "erpnext.templates.utils.send_message"} @@ -485,7 +482,7 @@ doc_events = { "Sales Invoice": { "on_submit": [ "erpnext.regional.italy.utils.sales_invoice_on_submit", - "erpnext.accounts.doctype.subscription.subscription.update_subscription_state", # @dokos + "erpnext.accounts.doctype.subscription.subscription.update_subscription_state", # @dokos ], "on_cancel": [ "erpnext.regional.italy.utils.sales_invoice_on_cancel",