From 60a7b6654d70e3efb323b6b540201063f66d17e4 Mon Sep 17 00:00:00 2001 From: Xavi Hermoso Date: Tue, 28 Oct 2025 11:45:10 +0100 Subject: [PATCH] Copy productions at once when splitting closes #14325 --- modules/production_split/production.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/production_split/production.py b/modules/production_split/production.py index 7dc54ecd4f..4340cbefe5 100644 --- a/modules/production_split/production.py +++ b/modules/production_split/production.py @@ -36,6 +36,7 @@ class Production(metaclass=PoolMeta): Uom = pool.get('product.uom') productions = [self] + n_productions = 0 remainder = Uom.compute_qty(self.unit, self.quantity, unit) if remainder <= quantity: return productions @@ -47,16 +48,18 @@ class Production(metaclass=PoolMeta): count -= 1 while (remainder > quantity and (count or count is None)): - productions.extend(self.copy([self], { + n_productions += 1 + remainder -= quantity + remainder = unit.round(remainder) + if count: + count -= 1 + if n_productions: + productions.extend(self.copy([self] * n_productions, { 'quantity': quantity, 'unit': unit.id, 'inputs': None, 'outputs': None, })) - remainder -= quantity - remainder = unit.round(remainder) - if count: - count -= 1 assert remainder >= 0 if remainder: productions.extend(self.copy([self], {