Merge pull request #6687 from KanchanChauhan/lead-changes

Contact by and contact date validations
This commit is contained in:
Nabin Hait 2016-10-24 16:44:08 +05:30 committed by GitHub
commit 1f3771cdf1

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _ 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 frappe.model.mapper import get_mapped_doc
from erpnext.controllers.selling_controller import SellingController from erpnext.controllers.selling_controller import SellingController
@ -38,11 +38,16 @@ class Lead(SellingController):
validate_email_add(self.email_id, True) validate_email_add(self.email_id, True)
if self.email_id == self.lead_owner: if self.email_id == self.lead_owner:
# Lead Owner cannot be same as the Lead frappe.throw(_("Lead Owner cannot be same as the Lead"))
self.lead_owner = None
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) 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): def on_update(self):
self.add_calendar_event() self.add_calendar_event()