From d0d5fedd484339038064f803460978eaa38196b1 Mon Sep 17 00:00:00 2001 From: GangaManoj Date: Tue, 22 Jun 2021 00:22:08 +0530 Subject: [PATCH] fix(Sales Invoice): Print appropriate message if item.asset is missing when the Item is a Fixed Asset --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index c835debce6..ff1e14b30a 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -916,7 +916,11 @@ class SalesInvoice(SellingController): for item in self.get("items"): if flt(item.base_net_amount, item.precision("base_net_amount")): if item.is_fixed_asset: - asset = frappe.get_doc("Asset", item.asset) + if item.get('asset'): + asset = frappe.get_doc("Asset", item.asset) + else: + frappe.throw(_("Enter Asset linked with Item {0}: {1} in row {2}.") + .format(item.item_code, item.item_name, item.idx)) if (len(asset.finance_books) > 1 and not item.finance_book and asset.finance_books[0].finance_book):