From 18bb3ac71bac3d1a71a9dab37b5731bbc0add8e0 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Fri, 5 Jan 2018 09:56:36 +0100 Subject: [PATCH] [FIX] mrp: in move validation, take into account the owner Before this commit, the special mrp validate_move method did a call to quants_move with an incomplete signature. IN the use case, that we want to make "own" produced quantities by a third party (maquila), we can do so in downstream modules by restrict the partner on the move so that any moved (or created) quants will belong to this partner (owner). This is certainly important for the case where finished products are not your own property. Courtesy of blaggacao. Closes #21072 --- addons/mrp/models/stock_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index b53685eb9fc..6671cb0a215 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -282,7 +282,7 @@ class StockMove(models.Model): preferred_domain_list = [preferred_domain] + [fallback_domain] + [fallback_domain2] if move.has_tracking == 'none': quants = quant_obj.quants_get_preferred_domain(move.product_qty, move, domain=main_domain, preferred_domain_list=preferred_domain_list) - self.env['stock.quant'].quants_move(quants, move, move.location_dest_id) + self.env['stock.quant'].quants_move(quants, move, move.location_dest_id, owner_id=move.restrict_partner_id.id) else: for movelot in move.active_move_lot_ids: if float_compare(movelot.quantity_done, 0, precision_rounding=rounding) > 0: @@ -290,7 +290,7 @@ class StockMove(models.Model): raise UserError(_('You need to supply a lot/serial number.')) qty = move.product_uom._compute_quantity(movelot.quantity_done, move.product_id.uom_id) quants = quant_obj.quants_get_preferred_domain(qty, move, lot_id=movelot.lot_id.id, domain=main_domain, preferred_domain_list=preferred_domain_list) - self.env['stock.quant'].quants_move(quants, move, move.location_dest_id, lot_id = movelot.lot_id.id) + self.env['stock.quant'].quants_move(quants, move, move.location_dest_id, lot_id = movelot.lot_id.id, owner_id=move.restrict_partner_id.id) moves_to_unreserve |= move # Next move in production order if move.move_dest_id and move.move_dest_id.state not in ('done', 'cancel'):