minor fix in account and account utils (#14432)
This commit is contained in:
parent
65994210f6
commit
88a90ff3b5
@ -20,14 +20,16 @@ class Account(NestedSet):
|
||||
self.set_onload("can_freeze_account", True)
|
||||
|
||||
def autoname(self):
|
||||
self.name = get_account_autoname(self.account_number, self.account_name, self.company)
|
||||
from erpnext.accounts.utils import get_doc_name_autoname
|
||||
self.name = get_doc_name_autoname(self.account_number, self.account_name, None, self.company)
|
||||
|
||||
def validate(self):
|
||||
from erpnext.accounts.utils import validate_field_number
|
||||
if frappe.local.flags.allow_unverified_charts:
|
||||
return
|
||||
self.validate_parent()
|
||||
self.validate_root_details()
|
||||
validate_account_number(self.name, self.account_number, self.company)
|
||||
validate_field_number("Account", self.name, self.account_number, self.company, "account_number")
|
||||
self.validate_group_or_ledger()
|
||||
self.set_root_and_report_type()
|
||||
self.validate_mandatory()
|
||||
|
@ -13,7 +13,6 @@ class CostCenter(NestedSet):
|
||||
def autoname(self):
|
||||
self.name = self.cost_center_name.strip() + ' - ' + \
|
||||
frappe.db.get_value("Company", self.company, "abbr")
|
||||
|
||||
|
||||
def validate(self):
|
||||
self.validate_mandatory()
|
||||
|
@ -805,11 +805,12 @@ def validate_field_number(doctype_name, name, field_value, company, field_name):
|
||||
|
||||
def get_doc_name_autoname(field_value, doc_title, name, company):
|
||||
''' append title with prefix as number and suffix as company's abbreviation separated by '-' '''
|
||||
if company:
|
||||
if name:
|
||||
name_split=name.split("-")
|
||||
parts = [doc_title.strip(), name_split[len(name_split)-1].strip()]
|
||||
else:
|
||||
parts = [doc_title.strip()]
|
||||
abbr = frappe.db.get_value("Company", company, ["abbr"], as_dict=True)
|
||||
parts = [doc_title.strip(), abbr.abbr]
|
||||
if cstr(field_value).strip():
|
||||
parts.insert(0, cstr(field_value).strip())
|
||||
return ' - '.join(parts)
|
||||
|
Loading…
x
Reference in New Issue
Block a user