From fe59f13a0b59449e26fe84458178ce8de4b26a70 Mon Sep 17 00:00:00 2001 From: Dipen Gala Date: Fri, 12 Jun 2026 15:56:46 +0530 Subject: [PATCH] fix: remove unnecessary expense head warning for purchase invoices with update stock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a Purchase Invoice is created with `update_stock = 1`, the system automatically replaces the item's expense account with the correct inventory account for perpetual inventory. This is expected behaviour, but a `frappe.msgprint` warning was being shown to the user: "Expense Head changed to Stock In Hand because account Cost of Goods Sold is not linked to warehouse Stores or it is not the default inventory account." The message is purely informational, provides no actionable guidance, and confuses users who deliberately enable Update Stock. The underlying account substitution logic is unchanged; only the popup is suppressed. The two other `msgprint` calls (for the Purchase-Receipt-linked and no-Purchase-Receipt flows) are intentionally preserved — those surface a genuine change in behaviour that users may not expect. --- .../doctype/purchase_invoice/purchase_invoice.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 06d5b341aef..c25d0c2410d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -483,16 +483,6 @@ class PurchaseInvoice(BuyingController): if self.update_stock and item.warehouse and (not item.from_warehouse): _inv_dict = self.get_inventory_account_dict(item, inventory_account_map) - if for_validate and item.expense_account and item.expense_account != _inv_dict["account"]: - msg = _( - "Row {0}: Expense Head changed to {1} because account {2} is not linked to warehouse {3} or it is not the default inventory account" - ).format( - item.idx, - frappe.bold(_inv_dict["account"]), - frappe.bold(item.expense_account), - frappe.bold(item.warehouse), - ) - frappe.msgprint(msg, title=_("Expense Head Changed")) item.expense_account = _inv_dict["account"] else: # check if 'Stock Received But Not Billed' account is credited in Purchase receipt or not