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)