[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) <arm@odoo.com>
Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
This commit is contained in:
clesgow
2023-08-14 09:16:43 +02:00
parent 82e5b753d4
commit 70e011e04b
+1 -1
View File
@@ -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