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.
This commit is contained in:
Mihir Kandoi
2026-06-25 14:39:08 +05:30
parent 934b5065fc
commit e8e50edbed

View File

@@ -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,