From 7fa800b87449fea05306f2ae31e8e03801e9ead8 Mon Sep 17 00:00:00 2001 From: thomasantony12 Date: Sun, 12 Oct 2025 11:18:03 +0530 Subject: [PATCH 1/3] fix: Batch ordering based on the method mentioned in settings --- erpnext/stock/doctype/batch/batch.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index 52af15e158a..9dbc155fb46 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -239,6 +239,7 @@ def get_batch_qty( get_auto_batch_nos, ) + stock_settings = frappe.get_cached_doc("Stock Settings") batchwise_qty = defaultdict(float) kwargs = frappe._dict( { @@ -247,6 +248,7 @@ def get_batch_qty( "posting_date": posting_date, "posting_time": posting_time, "batch_no": batch_no, + "based_on": stock_settings.pick_serial_and_batch_based_on, "ignore_voucher_nos": ignore_voucher_nos, "for_stock_levels": for_stock_levels, "consider_negative_batches": consider_negative_batches, From fab7f9ee53ef1db331269c4ff087bced16820c3f Mon Sep 17 00:00:00 2001 From: thomasantony12 Date: Sun, 12 Oct 2025 18:05:29 +0530 Subject: [PATCH 2/3] chore: use get_single_value instead of get_cached_doc --- erpnext/stock/doctype/batch/batch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index 9dbc155fb46..b65a9d2ec40 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -239,7 +239,7 @@ def get_batch_qty( get_auto_batch_nos, ) - stock_settings = frappe.get_cached_doc("Stock Settings") + based_on = frappe.get_single_value("Stock Settings", "pick_serial_and_batch_based_on") batchwise_qty = defaultdict(float) kwargs = frappe._dict( { @@ -248,7 +248,7 @@ def get_batch_qty( "posting_date": posting_date, "posting_time": posting_time, "batch_no": batch_no, - "based_on": stock_settings.pick_serial_and_batch_based_on, + "based_on": based_on, "ignore_voucher_nos": ignore_voucher_nos, "for_stock_levels": for_stock_levels, "consider_negative_batches": consider_negative_batches, From 1717a7c983d79602da02db5ad125288076400870 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 13 Oct 2025 19:26:34 +0530 Subject: [PATCH 3/3] refactor: move value inline --- erpnext/stock/doctype/batch/batch.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index b65a9d2ec40..3b3b8ffcfbd 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -239,7 +239,6 @@ def get_batch_qty( get_auto_batch_nos, ) - based_on = frappe.get_single_value("Stock Settings", "pick_serial_and_batch_based_on") batchwise_qty = defaultdict(float) kwargs = frappe._dict( { @@ -248,7 +247,7 @@ def get_batch_qty( "posting_date": posting_date, "posting_time": posting_time, "batch_no": batch_no, - "based_on": based_on, + "based_on": frappe.get_single_value("Stock Settings", "pick_serial_and_batch_based_on"), "ignore_voucher_nos": ignore_voucher_nos, "for_stock_levels": for_stock_levels, "consider_negative_batches": consider_negative_batches,