[fix] salary component fix for abbr
This commit is contained in:
parent
c040015bb5
commit
dc89916aa9
@ -5,7 +5,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe import _
|
from frappe.model.naming import append_number_if_name_exists
|
||||||
|
|
||||||
class SalaryComponent(Document):
|
class SalaryComponent(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@ -13,12 +13,10 @@ class SalaryComponent(Document):
|
|||||||
|
|
||||||
def validate_abbr(self):
|
def validate_abbr(self):
|
||||||
if not self.salary_component_abbr:
|
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()
|
self.salary_component_abbr = self.salary_component_abbr.strip()
|
||||||
|
|
||||||
if self.get('__islocal') and len(self.salary_component_abbr) > 5:
|
self.salary_component_abbr = append_number_if_name_exists('Salary Component',
|
||||||
frappe.throw(_("Abbreviation cannot have more than 5 characters"))
|
self.salary_component_abbr, 'salary_component_abbr', separator='_')
|
||||||
|
|
||||||
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))
|
|
Loading…
x
Reference in New Issue
Block a user