[fix] Validate Company in Account autoname

This commit is contained in:
Anand Doshi 2016-05-11 13:27:18 +05:30
parent 719504a0fe
commit 19fec06366

View File

@ -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: