From f4f886c7d1745812e88279c86a056f6e8ce22a94 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 11 Jul 2023 13:38:13 +0530 Subject: [PATCH] fix: Validate for missing expense account (#36078) fix: Validate for missing expense account (#36078) * fix: Validate for missing expense account * fix: Validate for missing expense account (cherry picked from commit ce9164ec69f6cbc67edae644dd0e0e17ff39af74) Co-authored-by: Deepesh Garg --- erpnext/controllers/stock_controller.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index befde71775a..4f0c8a9a54f 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -201,6 +201,12 @@ class StockController(AccountsController): warehouse_asset_account = warehouse_account[item_row.get("warehouse")]["account"] expense_account = frappe.get_cached_value("Company", self.company, "default_expense_account") + if not expense_account: + frappe.throw( + _( + "Please set default cost of goods sold account in company {0} for booking rounding gain and loss during stock transfer" + ).format(frappe.bold(self.company)) + ) gl_list.append( self.get_gl_dict(