From fa76e8ac7f89fd43d54ab78cbe9ec96a925095d8 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 10:54:04 +0530 Subject: [PATCH] fix: changed qty validation from qty field to stock_qty (backport #54352) (#54357) fix: changed qty validation from qty field to stock_qty (#54352) (cherry picked from commit ba01d66c24a7efe56dd433155ba5aece3d33bb63) Co-authored-by: Jatin3128 <140256508+Jatin3128@users.noreply.github.com> --- erpnext/selling/doctype/quotation/quotation.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 4583b6cc1e5..3eb82af1b01 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -191,7 +191,7 @@ class Quotation(SellingController): ) for row in self._items: - if row.name not in ordered_items or row.qty > ordered_items[row.name]: + if row.name not in ordered_items or row.stock_qty > ordered_items[row.name]: return "Partially Ordered" return "Ordered" @@ -413,9 +413,9 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False, ar target.run_method("calculate_taxes_and_totals") def update_item(obj, target, source_parent): - balance_qty = obj.qty if is_unit_price_row(obj) else obj.qty - ordered_items.get(obj.name, 0.0) - target.qty = balance_qty if balance_qty > 0 else 0 - target.stock_qty = flt(target.qty) * flt(obj.conversion_factor) + balance_stock_qty = obj.stock_qty - ordered_items.get(obj.name, 0.0) + target.stock_qty = balance_stock_qty if balance_stock_qty > 0 else 0 + target.qty = flt(target.stock_qty) / flt(obj.conversion_factor) if obj.against_blanket_order: target.against_blanket_order = obj.against_blanket_order @@ -429,7 +429,7 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False, ar 2. If selections: Is Alternative Item/Has Alternative Item: Map if selected and adequate qty 3. If no selections: Simple row: Map if adequate qty """ - if not ((item.qty > ordered_items.get(item.name, 0.0)) or is_unit_price_row(item)): + if not ((item.stock_qty > ordered_items.get(item.name, 0.0)) or is_unit_price_row(item)): return False if not selected_rows: