From a1cedbc7b27ec7d101b40f6186760f02e83b4a09 Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Mon, 24 Oct 2016 12:41:45 +0530 Subject: [PATCH] Contact by and contact date validations --- erpnext/crm/doctype/lead/lead.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py index 605b9e9ecd..18c0db44e0 100644 --- a/erpnext/crm/doctype/lead/lead.py +++ b/erpnext/crm/doctype/lead/lead.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe from frappe import _ -from frappe.utils import cstr, validate_email_add, cint, comma_and, has_gravatar +from frappe.utils import cstr, validate_email_add, cint, comma_and, has_gravatar, nowdate from frappe.model.mapper import get_mapped_doc from erpnext.controllers.selling_controller import SellingController @@ -38,11 +38,16 @@ class Lead(SellingController): validate_email_add(self.email_id, True) if self.email_id == self.lead_owner: - # Lead Owner cannot be same as the Lead - self.lead_owner = None + frappe.throw(_("Lead Owner cannot be same as the Lead")) + + if self.email_id == self.contact_by: + frappe.throw(_("Next Contact By cannot be same as the Lead Email id")) self.image = has_gravatar(self.email_id) + if self.contact_date and self.contact_date < nowdate(): + frappe.throw(_("Next Contact Date cannot be in the past")) + def on_update(self): self.add_calendar_event()