mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 07:28:39 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user