[FIX] stock_account: value extra move MTO

- Create 2 products A & B in MTO, B with 'Buy' route + supplier
- Create a BOM for A: 1 Unit of B
- Create a MO for 1 Unit of A
- In the PO created, change the quantity from 1 to 2, receive the
  products
- In the MO, produce the unit and use 2 units of B

The extra move of B is not valued.

This is because the list of move to value is created before calling
`super()`. Indeed, the extra move is created in `super()`, and
moreover since this extra move is MTS (not MTO), the move line is
properly linked to the right move (unlike in #39121).

We add the extra move to the list of moves to value.

opw-2087592

closes odoo/odoo#39484

X-original-commit: 00737ffeb8604f1713b559fbd3061b572435b413
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2019-10-29 08:15:42 +00:00
committed by fw-bot
parent 54d846ab1c
commit baa243bb46
@@ -245,6 +245,13 @@ class StockMove(models.Model):
res = super(StockMove, self)._action_done(cancel_backorder=cancel_backorder)
# '_action_done' might have created an extra move to be valued
for move in res - self:
for valued_type in self._get_valued_types():
if getattr(move, '_is_%s' % valued_type)():
valued_moves[valued_type] |= move
continue
stock_valuation_layers = self.env['stock.valuation.layer'].sudo()
# Create the valuation layers in batch by calling `moves._create_valued_type_svl`.
for valued_type in self._get_valued_types():