From e8e50edbed1373d87ce8e953e58c02e27c843fbb Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Thu, 25 Jun 2026 14:39:08 +0530 Subject: [PATCH] fix(postgres): pricing rule priority order diverges on Postgres _get_pricing_rules orders by priority desc; get_pricing_rules then reads pricing_rules[0].has_priority. priority is a Select (varchar): unset is '' on MariaDB but NULL on Postgres, which sorts to the top under DESC and flips the selection. Order by coalesce(priority, '') desc so the unset value sorts last ('' is the text minimum) on both backends. --- erpnext/accounts/doctype/pricing_rule/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 9fabb2bdc89..1dd6febc0e7 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -152,7 +152,7 @@ def _get_pricing_rules(apply_on, args, values): and {child_doc}.parent = `tabPricing Rule`.name and `tabPricing Rule`.disable = 0 and `tabPricing Rule`.{transaction_type} = 1 {warehouse_cond} {conditions} - order by `tabPricing Rule`.priority desc, + order by coalesce(`tabPricing Rule`.priority, '') desc, `tabPricing Rule`.name desc""".format( child_doc=child_doc, apply_on_field=apply_on_field,