Skip to content

Commit

Permalink
Merge pull request #42596 from Didiman1998/bugfix/fix-opportunity-con…
Browse files Browse the repository at this point in the history
…tact-address-bug

fix: changes in opportunity.py to show contacts and addresses created from opportunity
  • Loading branch information
shariquerik authored Aug 7, 2024
2 parents efadf94 + 511a0b9 commit 47c2127
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions erpnext/crm/doctype/opportunity/opportunity.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,26 @@ class Opportunity(TransactionBase, CRMNote):

def onload(self):
ref_doc = frappe.get_doc(self.opportunity_from, self.party_name)

load_address_and_contact(ref_doc)
load_address_and_contact(self)

ref_doc_contact_list = ref_doc.get("__onload").get("contact_list")
opportunity_doc_contact_list = [
contact
for contact in self.get("__onload").get("contact_list")
if contact not in ref_doc_contact_list
]
ref_doc_contact_list.extend(opportunity_doc_contact_list)
ref_doc.set_onload("contact_list", ref_doc_contact_list)

ref_doc_addr_list = ref_doc.get("__onload").get("addr_list")
opportunity_doc_addr_list = [
addr for addr in self.get("__onload").get("addr_list") if addr not in ref_doc_addr_list
]
ref_doc_addr_list.extend(opportunity_doc_addr_list)
ref_doc.set_onload("addr_list", ref_doc_addr_list)

self.set("__onload", ref_doc.get("__onload"))

def after_insert(self):
Expand Down

0 comments on commit 47c2127

Please sign in to comment.