From baa243bb46e3aab3ee188e29152ff392881c348b Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 28 Oct 2019 14:47:32 +0000 Subject: [PATCH] [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) --- addons/stock_account/models/stock_move.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/stock_account/models/stock_move.py b/addons/stock_account/models/stock_move.py index 517e720ae23..b72c70d3709 100644 --- a/addons/stock_account/models/stock_move.py +++ b/addons/stock_account/models/stock_move.py @@ -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():