From 70e011e04bc594f3c5166d3d0ea94e4e9eace295 Mon Sep 17 00:00:00 2001 From: clesgow Date: Fri, 11 Aug 2023 09:54:10 +0000 Subject: [PATCH] [FIX] mrp: force deterministic order on WO duration Previous fix c7616df enforced an order on the workorders for the computation of the time_cycle. However, 'asc' is used by default in order clauses if not explicitly written. This resulted in using the oldest workorder instead of the newest to compute the duration. closes odoo/odoo#131830 X-original-commit: a69d13abbc81b36aaf717f8e4d665fda8580c1fc Signed-off-by: Arnold Moyaux (arm) Signed-off-by: Quentin Wolfs (quwo) --- addons/mrp/models/mrp_routing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/models/mrp_routing.py b/addons/mrp/models/mrp_routing.py index 6ab251f46f9..5e217cb5ee6 100644 --- a/addons/mrp/models/mrp_routing.py +++ b/addons/mrp/models/mrp_routing.py @@ -75,7 +75,7 @@ class MrpRoutingWorkcenter(models.Model): ('qty_produced', '>', 0), ('state', '=', 'done')], limit=operation.time_mode_batch, - order="date_finished desc, id") + order="date_finished desc, id desc") # To compute the time_cycle, we can take the total duration of previous operations # but for the quantity, we will take in consideration the qty_produced like if the capacity was 1. # So producing 50 in 00:10 with capacity 2, for the time_cycle, we assume it is 25 in 00:10