mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
[fix] Validate company abbr
This commit is contained in:
@@ -27,15 +27,21 @@ class Company(Document):
|
|||||||
return exists
|
return exists
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
self.validate_abbr()
|
||||||
|
self.validate_default_accounts()
|
||||||
|
self.validate_currency()
|
||||||
|
|
||||||
|
def validate_abbr(self):
|
||||||
self.abbr = self.abbr.strip()
|
self.abbr = self.abbr.strip()
|
||||||
|
|
||||||
if self.get('__islocal') and len(self.abbr) > 5:
|
if self.get('__islocal') and len(self.abbr) > 5:
|
||||||
frappe.throw(_("Abbreviation cannot have more than 5 characters"))
|
frappe.throw(_("Abbreviation cannot have more than 5 characters"))
|
||||||
|
|
||||||
if not self.abbr.strip():
|
if not self.abbr.strip():
|
||||||
frappe.throw(_("Abbreviation is mandatory"))
|
frappe.throw(_("Abbreviation is mandatory"))
|
||||||
|
|
||||||
self.validate_default_accounts()
|
if frappe.db.sql("select abbr from tabCompany where name!=%s and abbr=%s", (self.name, self.abbr)):
|
||||||
self.validate_currency()
|
frappe.throw(_("Abbreviation already used for another company"))
|
||||||
|
|
||||||
def validate_default_accounts(self):
|
def validate_default_accounts(self):
|
||||||
for field in ["default_bank_account", "default_cash_account", "default_receivable_account", "default_payable_account",
|
for field in ["default_bank_account", "default_cash_account", "default_receivable_account", "default_payable_account",
|
||||||
@@ -167,7 +173,7 @@ class Company(Document):
|
|||||||
frappe.defaults.clear_cache()
|
frappe.defaults.clear_cache()
|
||||||
|
|
||||||
def abbreviate(self):
|
def abbreviate(self):
|
||||||
self.abbr = ''.join([c[0].upper() for c in self.name.split()])
|
self.abbr = ''.join([c[0].upper() for c in self.company_name.split()])
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user