fix(asset): check if fixed asset account is set against company (#29189)
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index a18b03a..ee3ec8e 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -608,7 +608,17 @@
return purchase_document
def get_fixed_asset_account(self):
- return get_asset_category_account('fixed_asset_account', None, self.name, None, self.asset_category, self.company)
+ fixed_asset_account = get_asset_category_account('fixed_asset_account', None, self.name, None, self.asset_category, self.company)
+ if not fixed_asset_account:
+ frappe.throw(
+ _("Set {0} in asset category {1} for company {2}").format(
+ frappe.bold("Fixed Asset Account"),
+ frappe.bold(self.asset_category),
+ frappe.bold(self.company),
+ ),
+ title=_("Account not Found"),
+ )
+ return fixed_asset_account
def get_cwip_account(self, cwip_enabled=False):
cwip_account = None