[cleanup] validate_email_add

This commit is contained in:
Rushabh Mehta 2015-03-23 14:10:38 +05:30
parent 97cc4dd582
commit c2eae25d0e
5 changed files with 15 additions and 17 deletions

View File

@ -38,8 +38,7 @@ class Lead(SellingController):
frappe.throw(_("Campaign Name is required")) frappe.throw(_("Campaign Name is required"))
if self.email_id: if self.email_id:
if not validate_email_add(self.email_id): validate_email_add(self.email_id, True)
frappe.throw(_('{0} is not a valid email id').format(self.email_id))
if self.email_id == self.lead_owner: if self.email_id == self.lead_owner:
# Lead Owner cannot be same as the Lead # Lead Owner cannot be same as the Lead

View File

@ -62,8 +62,7 @@ def add_subscribers(name, email_list):
count = 0 count = 0
for email in email_list.replace(",", "\n").split("\n"): for email in email_list.replace(",", "\n").split("\n"):
email = email.strip() email = email.strip()
if not validate_email_add(email): validate_email_add(email, True)
frappe.throw(_("Invalid Email '{0}'").format(email))
if email: if email:
try: try:

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import getdate, validate_email_add, cint, today from frappe.utils import getdate, validate_email_add, today
from frappe.model.naming import make_autoname from frappe.model.naming import make_autoname
from frappe import throw, _, msgprint from frappe import throw, _, msgprint
import frappe.permissions import frappe.permissions
@ -110,10 +110,10 @@ class Employee(Document):
throw(_("Contract End Date must be greater than Date of Joining")) throw(_("Contract End Date must be greater than Date of Joining"))
def validate_email(self): def validate_email(self):
if self.company_email and not validate_email_add(self.company_email): if self.company_email:
throw(_("Please enter valid Company Email")) validate_email_add(self.company_email, True)
if self.personal_email and not validate_email_add(self.personal_email): if self.personal_email:
throw(_("Please enter valid Personal Email")) validate_email_add(self.personal_email, True)
def validate_status(self): def validate_status(self):
if self.status == 'Left' and not self.relieving_date: if self.status == 'Left' and not self.relieving_date:

View File

@ -10,16 +10,16 @@ def execute():
{"reconciliation_json": ["!=", ""]}): {"reconciliation_json": ["!=", ""]}):
start = False start = False
sr = frappe.get_doc("Stock Reconciliation", sr.name) sr = frappe.get_doc("Stock Reconciliation", sr.name)
for item in json.loads(sr.reconciliation_json): for row in json.loads(sr.reconciliation_json):
if start: if start:
sr.append("items", { sr.append("items", {
"item_code": item[0], "item_code": row[0],
"warehouse": item[1], "warehouse": row[1],
"qty": item[3] if len(item) > 2 else None, "qty": row[3] if len(row) > 2 else None,
"valuation_rate": item[4] if len(item) > 3 else None "valuation_rate": row[4] if len(row) > 3 else None
}) })
elif item[0]=="Item Code": elif row[0]=="Item Code":
start = True start = True

View File

@ -15,8 +15,8 @@ class Warehouse(Document):
self.name = self.warehouse_name + suffix self.name = self.warehouse_name + suffix
def validate(self): def validate(self):
if self.email_id and not validate_email_add(self.email_id): if self.email_id:
throw(_("Please enter valid Email Id")) validate_email_add(self.email_id, True)
self.update_parent_account() self.update_parent_account()