Copy productions at once when splitting

closes #14325
This commit is contained in:
Xavi Hermoso
2025-10-28 11:45:10 +01:00
parent fe44ee1a60
commit 60a7b6654d
+8 -5
View File
@@ -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], {