[fix] unique employee id validation for sales person

This commit is contained in:
Nabin Hait 2015-05-25 15:27:40 +05:30
parent c4fa74f51d
commit e2787cf2ec

View File

@ -29,5 +29,7 @@ class SalesPerson(NestedSet):
return frappe.db.get_value("User", user, "email") or user
def validate_employee_id(self):
if frappe.db.exists({"doctype": "Sales Person","employee": self.employee}):
frappe.throw("Another sales person with the same employee id exists.", frappe.DuplicateEntryError)
sales_person = frappe.db.get_value("Sales Person", {"employee": self.employee})
if sales_person and sales_person != self.name:
frappe.throw(_("Another sales person {0} exists with the same employee id").format(sales_person))