* Fix for Issue #26798 This PR is a fix for GitHub Issue 26798: https://github.com/frappe/erpnext/issues/26798 TLDR: When an Address is updated, and that Address is a Customer's Primary Address, update the Read Only field `customer.primary_address` * Update address.py Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
This commit is contained in:
parent
c8f22e5524
commit
1a919773d7
@ -1,7 +1,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.contacts.doctype.address.address import Address
|
from frappe.contacts.doctype.address.address import Address
|
||||||
from frappe.contacts.doctype.address.address import get_address_templates
|
from frappe.contacts.doctype.address.address import get_address_templates, get_address_display
|
||||||
|
|
||||||
class ERPNextAddress(Address):
|
class ERPNextAddress(Address):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@ -22,6 +22,16 @@ class ERPNextAddress(Address):
|
|||||||
frappe.throw(_("Address needs to be linked to a Company. Please add a row for Company in the Links table."),
|
frappe.throw(_("Address needs to be linked to a Company. Please add a row for Company in the Links table."),
|
||||||
title=_("Company Not Linked"))
|
title=_("Company Not Linked"))
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_shipping_address(company, address = None):
|
def get_shipping_address(company, address = None):
|
||||||
filters = [
|
filters = [
|
||||||
|
Loading…
Reference in New Issue
Block a user