[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"))
if self.email_id:
if not validate_email_add(self.email_id):
frappe.throw(_('{0} is not a valid email id').format(self.email_id))
validate_email_add(self.email_id, True)
if self.email_id == self.lead_owner:
# Lead Owner cannot be same as the Lead

View File

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

View File

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

View File

@ -10,16 +10,16 @@ def execute():
{"reconciliation_json": ["!=", ""]}):
start = False
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:
sr.append("items", {
"item_code": item[0],
"warehouse": item[1],
"qty": item[3] if len(item) > 2 else None,
"valuation_rate": item[4] if len(item) > 3 else None
"item_code": row[0],
"warehouse": row[1],
"qty": row[3] if len(row) > 2 else None,
"valuation_rate": row[4] if len(row) > 3 else None
})
elif item[0]=="Item Code":
elif row[0]=="Item Code":
start = True

View File

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