fix: Auto update company address check on linking with company

This commit is contained in:
Deepesh Garg 2021-10-21 15:37:59 +05:30
parent 2849297471
commit c6d06816cf

View File

@ -10,6 +10,7 @@ from frappe.contacts.doctype.address.address import (
class ERPNextAddress(Address):
def validate(self):
self.validate_reference()
self.update_compnay_address()
super(ERPNextAddress, self).validate()
def link_address(self):
@ -19,6 +20,11 @@ class ERPNextAddress(Address):
return super(ERPNextAddress, self).link_address()
def update_compnay_address(self):
for link in self.get('links'):
if link.link_doctype == 'Company':
self.is_your_company_address = 1
def validate_reference(self):
if self.is_your_company_address and not [
row for row in self.links if row.link_doctype == "Company"