From 8a055dc797cc4cf7ade632519a3ab6a0e3c77b1b Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Tue, 8 Aug 2023 08:01:05 +0000 Subject: [PATCH] [FIX] mrp: WO duration nondeterministic Usecase to reproduce: - Set operation time base on last workorder - Create 2 MO - On first MO, set 15min as duration - On second MO, set 10min as duration - Validate both MO at the same time - The duraction expected on the operation could be now 10 or 15min It happens because the search in the compute is only base on date. And when both MO are validated at the same time, it's not enough closes odoo/odoo#131307 X-original-commit: cad75ac78b61046352c39d3f3b7717cfbad42c8b Signed-off-by: Arnold Moyaux (arm) --- 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 c53d4d4e528..6ab251f46f9 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") + order="date_finished desc, id") # 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