From 89f516c32b248e5d6230464f0c276cd38cf7f147 Mon Sep 17 00:00:00 2001
From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com>
Date: Thu, 21 Jul 2022 13:57:03 +0530
Subject: [PATCH] fix: assign duplicate_items_msg outside conditional (backport
#31639) (#31650)
fix: assign duplicate_items_msg outside conditional (#31639)
duplicate_items_msg was defined inside if the statement of stock_item so when duplicate was found in non_stock_item it raised referenced before assignment
(cherry picked from commit 8e23c6ad69dee213f0252d2b231317490fab760f)
Co-authored-by: Maharshi Patel <39730881+maharshivpatel@users.noreply.github.com>
---
erpnext/controllers/selling_controller.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 70e205619d9..a3d41ab29af 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -615,13 +615,13 @@ class SellingController(StockController):
stock_items = [d.item_code, d.description, d.warehouse, ""]
non_stock_items = [d.item_code, d.description]
+ duplicate_items_msg = _("Item {0} entered multiple times.").format(frappe.bold(d.item_code))
+ duplicate_items_msg += "
"
+ duplicate_items_msg += _("Please enable {} in {} to allow same item in multiple rows").format(
+ frappe.bold("Allow Item to Be Added Multiple Times in a Transaction"),
+ get_link_to_form("Selling Settings", "Selling Settings"),
+ )
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1:
- duplicate_items_msg = _("Item {0} entered multiple times.").format(frappe.bold(d.item_code))
- duplicate_items_msg += "
"
- duplicate_items_msg += _("Please enable {} in {} to allow same item in multiple rows").format(
- frappe.bold("Allow Item to Be Added Multiple Times in a Transaction"),
- get_link_to_form("Selling Settings", "Selling Settings"),
- )
if stock_items in check_list:
frappe.throw(duplicate_items_msg)
else: