From c868de324d6aff7ba32e230007c47397cd893206 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 23 Jun 2026 22:02:00 +0530 Subject: [PATCH] =?UTF-8?q?Revert=20"fix(stock):=20make=20get=5Fitem=5Fpri?= =?UTF-8?q?ce=20NULL=20ordering=20match=20across=20engines=20(P=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 116ef44ddbe7930195d7cf038f4160451027ef43. --- erpnext/stock/get_item_details.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index d774ba83c2e..b11868347ea 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -1234,10 +1234,7 @@ def get_item_price( & (ip.price_list == pctx.price_list) & (IfNull(ip.uom, "").isin(["", pctx.uom])) ) - # IfNull so a NULL valid_from sorts last under DESC on both engines: MariaDB sorts NULL last - # for DESC, but Postgres defaults to NULLS FIRST, which would otherwise make a NULL-valid_from - # price win the LIMIT 1 over the most-recent dated price. - .orderby(IfNull(ip.valid_from, "1900-01-01"), order=frappe.qb.desc) + .orderby(ip.valid_from, order=frappe.qb.desc) .orderby(IfNull(ip.batch_no, ""), order=frappe.qb.desc) .orderby(ip.uom, order=frappe.qb.desc) .limit(1)