[cleanup] validate_email_add
diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py
index f0b48b4..49a4e3d 100644
--- a/erpnext/crm/doctype/lead/lead.py
+++ b/erpnext/crm/doctype/lead/lead.py
@@ -38,8 +38,7 @@
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
diff --git a/erpnext/crm/doctype/newsletter_list/newsletter_list.py b/erpnext/crm/doctype/newsletter_list/newsletter_list.py
index 973955d..cee68c9 100644
--- a/erpnext/crm/doctype/newsletter_list/newsletter_list.py
+++ b/erpnext/crm/doctype/newsletter_list/newsletter_list.py
@@ -62,8 +62,7 @@
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:
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index b1e0161..4ba3e96 100644
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -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 @@
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:
diff --git a/erpnext/patches/v5_0/convert_stock_reconciliation.py b/erpnext/patches/v5_0/convert_stock_reconciliation.py
index 4f856ea..cc9135a 100644
--- a/erpnext/patches/v5_0/convert_stock_reconciliation.py
+++ b/erpnext/patches/v5_0/convert_stock_reconciliation.py
@@ -10,16 +10,16 @@
{"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
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index 7fa4af0..1643f93 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -15,8 +15,8 @@
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()