Browse Source

Merge pull request #28440 from anupamvs/crm-lead-validate-cleanup-develop

fix: lead validate function cleanup
develop
Anupam Kumar 3 years ago
committed by GitHub
parent
commit
66a10c0e73
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      erpnext/crm/doctype/lead/lead.py

17
erpnext/crm/doctype/lead/lead.py

@ -8,7 +8,6 @@ from frappe.contacts.address_and_contact import load_address_and_contact
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,
@ -39,11 +38,7 @@ class Lead(SellingController):
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:
@ -75,6 +70,16 @@ class Lead(SellingController):
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()

Loading…
Cancel
Save