[fix] salary component fix for abbr
diff --git a/erpnext/hr/doctype/salary_component/salary_component.py b/erpnext/hr/doctype/salary_component/salary_component.py
index c02d952..35d274c 100644
--- a/erpnext/hr/doctype/salary_component/salary_component.py
+++ b/erpnext/hr/doctype/salary_component/salary_component.py
@@ -5,7 +5,7 @@
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
-from frappe import _
+from frappe.model.naming import append_number_if_name_exists
class SalaryComponent(Document):
def validate(self):
@@ -13,12 +13,10 @@
def validate_abbr(self):
if not self.salary_component_abbr:
- self.salary_component_abbr = ''.join([c[0] for c in self.salary_component.split()]).upper()
+ self.salary_component_abbr = ''.join([c[0] for c in
+ self.salary_component.split()]).upper()
self.salary_component_abbr = self.salary_component_abbr.strip()
- if self.get('__islocal') and len(self.salary_component_abbr) > 5:
- frappe.throw(_("Abbreviation cannot have more than 5 characters"))
-
- if frappe.db.sql("select salary_component_abbr from `tabSalary Component` where name!=%s and salary_component_abbr=%s", (self.name, self.salary_component_abbr)):
- frappe.throw(_("Abbreviation {0} already used for another salary component").format(self.salary_component_abbr))
\ No newline at end of file
+ self.salary_component_abbr = append_number_if_name_exists('Salary Component',
+ self.salary_component_abbr, 'salary_component_abbr', separator='_')
\ No newline at end of file