[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
This commit is contained in:
Josse Colpaert
2018-01-05 10:45:26 +01:00
parent 10af3284ab
commit 18bb3ac71b
+2 -2
View File
@@ -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'):