Skip to content

Commit

Permalink
fix: update contact image if lead image is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Sep 1, 2023
1 parent 716cad5 commit 61f3ea5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crm/crm/doctype/crm_lead/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ def validate_contact(self):
link = frappe.db.exists("Dynamic Link", {"link_doctype": "CRM Lead", "link_name": self.name})

if link:
for field in ["first_name", "last_name", "email", "mobile_no", "phone", "salutation"]:
for field in ["first_name", "last_name", "email", "mobile_no", "phone", "salutation", "image"]:
if self.has_value_changed(field):
contact = frappe.db.get_value("Dynamic Link", link, "parent")
contact_doc = frappe.get_doc("Contact", contact)
contact_doc.update({
"first_name": self.first_name or self.lead_name,
"last_name": self.last_name,
"salutation": self.salutation,
"image": self.image or "",
})
if self.has_value_changed("email"):
contact_doc.email_ids = []
Expand Down Expand Up @@ -106,6 +107,7 @@ def create_contact(self):
"gender": self.gender,
"designation": self.job_title,
"company_name": self.organization_name,
"image": self.image or "",
}
)

Expand Down

0 comments on commit 61f3ea5

Please sign in to comment.