From 93c186fea797b65e36cf0da116b3ce2289cb9179 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 29 Jun 2026 16:29:44 +0530 Subject: [PATCH] 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. --- erpnext/assets/doctype/asset_movement/asset_movement.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/assets/doctype/asset_movement/asset_movement.py b/erpnext/assets/doctype/asset_movement/asset_movement.py index 674be5c65b3..74ac5e55ee3 100644 --- a/erpnext/assets/doctype/asset_movement/asset_movement.py +++ b/erpnext/assets/doctype/asset_movement/asset_movement.py @@ -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() )