From 8f3eb6cb313d864a6e8d63a26e340e54d9d55db5 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 1 Jul 2026 09:10:19 +0530 Subject: [PATCH] fix(selling): tie-break POS customer contact pick for cross-engine parity The contact lookup orders only by is_primary_contact desc then takes contacts[0]; contacts commonly tie (the no-primary case), so MariaDB and Postgres could pick a different contact. Add a parent (contact name) tiebreaker. Co-Authored-By: Claude Opus 4.8 --- erpnext/selling/page/point_of_sale/point_of_sale.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py index 8f0bc136458..bd96ae38cc9 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.py +++ b/erpnext/selling/page/point_of_sale/point_of_sale.py @@ -464,6 +464,9 @@ def set_customer_info(fieldname: str, customer: str, value: str = ""): & (DynamicLink.link_doctype == "Customer") ) .orderby(Contact.is_primary_contact, order=Order.desc) + # tiebreaker: contacts tie on is_primary_contact (the common no-primary case) -> + # pick the same one on MariaDB and Postgres + .orderby(DynamicLink.parent, order=Order.asc) ) contacts = query.run(pluck=DynamicLink.parent)