[fix] Validate Company in Account autoname
This commit is contained in:
parent
719504a0fe
commit
19fec06366
@ -19,8 +19,12 @@ class Account(Document):
|
||||
self.get("__onload").can_freeze_account = True
|
||||
|
||||
def autoname(self):
|
||||
self.name = self.account_name.strip() + ' - ' + \
|
||||
frappe.db.get_value("Company", self.company, "abbr")
|
||||
# first validate if company exists
|
||||
company = frappe.db.get_value("Company", self.company, ["abbr", "name"], as_dict=True)
|
||||
if not company:
|
||||
frappe.throw(_('Company {0} does not exist').format(self.company))
|
||||
|
||||
self.name = self.account_name.strip() + ' - ' + company.abbr
|
||||
|
||||
def validate(self):
|
||||
if frappe.local.flags.allow_unverified_charts:
|
||||
|
Loading…
x
Reference in New Issue
Block a user