Replace _explode_move_values calls by _move call of production

This commit is contained in:
Cédric Krier
2024-03-16 21:07:22 +01:00
parent fe4cec2189
commit 0c5ac00c69
2 changed files with 5 additions and 9 deletions
+3 -7
View File
@@ -385,13 +385,9 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
move.currency = self.company.currency
return move
@fields.depends(methods=['_move'])
def _explode_move_values(self, type, bom_io, quantity):
return self._move(type, bom_io.product, bom_io.unit, quantity)
@fields.depends(
'bom', 'product', 'unit', 'quantity', 'inputs', 'outputs',
methods=['_explode_move_values'])
methods=['_move'])
def explode_bom(self):
pool = Pool()
Uom = pool.get('product.uom')
@@ -403,7 +399,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
inputs = []
for input_ in self.bom.inputs:
quantity = input_.compute_quantity(factor)
move = self._explode_move_values('input', input_, quantity)
move = self._move('input', input_.product, input_.unit, quantity)
if move:
inputs.append(move)
quantity = Uom.compute_qty(
@@ -414,7 +410,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
outputs = []
for output in self.bom.outputs:
quantity = output.compute_quantity(factor)
move = self._explode_move_values('output', output, quantity)
move = self._move('output', output.product, output.unit, quantity)
if move:
outputs.append(move)
self.outputs = outputs
+2 -2
View File
@@ -8,8 +8,8 @@ class Production(metaclass=PoolMeta):
__name__ = 'production'
@fields.depends('warehouse')
def _explode_move_values(self, type, bom_io, quantity):
move = super()._explode_move_values(type, bom_io, quantity)
def _move(self, type, product, unit, quantity):
move = super()._move(type, product, unit, quantity)
if move and type == 'output' and self.warehouse:
move.set_product_location(warehouse=self.warehouse.id)
return move