Skip to content

Commit

Permalink
Merge pull request #28440 from anupamvs/crm-lead-validate-cleanup-dev…
Browse files Browse the repository at this point in the history
…elop

fix: lead validate function cleanup
  • Loading branch information
anupamvs authored Dec 20, 2021
1 parent c5c7777 commit 66a10c0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions erpnext/crm/doctype/lead/lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from frappe.email.inbox import link_communication_to_document
from frappe.model.mapper import get_mapped_doc
from frappe.utils import (
cint,
comma_and,
cstr,
get_link_to_form,
Expand Down Expand Up @@ -39,11 +38,7 @@ def validate(self):
self.check_email_id_is_unique()
self.validate_email_id()
self.validate_contact_date()
self._prev = frappe._dict({
"contact_date": frappe.db.get_value("Lead", self.name, "contact_date") if (not cint(self.is_new())) else None,
"ends_on": frappe.db.get_value("Lead", self.name, "ends_on") if (not cint(self.is_new())) else None,
"contact_by": frappe.db.get_value("Lead", self.name, "contact_by") if (not cint(self.is_new())) else None,
})
self.set_prev()

def set_full_name(self):
if self.first_name:
Expand Down Expand Up @@ -75,6 +70,16 @@ def on_update(self):
self.add_calendar_event()
self.update_prospects()

def set_prev(self):
if self.is_new():
self._prev = frappe._dict({
"contact_date": None,
"ends_on": None,
"contact_by": None
})
else:
self._prev = frappe.db.get_value("Lead", self.name, ["contact_date", "ends_on", "contact_by"], as_dict=1)

def before_insert(self):
self.contact_doc = self.create_contact()

Expand Down

0 comments on commit 66a10c0

Please sign in to comment.