Skip to content

Commit

Permalink
feat: copy emails from lead to customer (#38647)
Browse files Browse the repository at this point in the history
feat: copy emails from lead to customer

(cherry picked from commit 906ac09)

Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com>
  • Loading branch information
mergify[bot] and barredterra authored Feb 5, 2024
1 parent a3f05cb commit 7952bf4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions erpnext/selling/doctype/customer/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def on_update(self):

if self.flags.is_new_doc:
self.link_lead_address_and_contact()
self.copy_communication()

self.update_customer_groups()

Expand Down Expand Up @@ -224,6 +225,17 @@ def link_lead_address_and_contact(self):
linked_doc.append("links", dict(link_doctype="Customer", link_name=self.name))
linked_doc.save(ignore_permissions=self.flags.ignore_permissions)

def copy_communication(self):
if not self.lead_name or not frappe.db.get_single_value(
"CRM Settings", "carry_forward_communication_and_comments"
):
return

from erpnext.crm.utils import copy_comments, link_communications

copy_comments("Lead", self.lead_name, self)
link_communications("Lead", self.lead_name, self)

def validate_name_with_customer_group(self):
if frappe.db.exists("Customer Group", self.name):
frappe.throw(
Expand Down

0 comments on commit 7952bf4

Please sign in to comment.