fix(assets): break latest asset-movement ties deterministically

get_latest_location_and_custodian ordered by transaction_date DESC only; equal-dated movements left the current location/custodian engine-dependent. Add asm.name DESC tiebreaker so both engines pick the same movement.
This commit is contained in:
Mihir Kandoi
2026-06-29 16:29:44 +05:30
parent 63ea907881
commit 93c186fea7

View File

@@ -139,6 +139,7 @@ class AssetMovement(Document):
.select(asm_item.target_location, asm_item.to_employee)
.where((asm_item.asset == asset) & (asm.company == self.company) & (asm.docstatus == 1))
.orderby(asm.transaction_date, order=frappe.qb.desc)
.orderby(asm.name, order=frappe.qb.desc)
.limit(1)
.run()
)