summaryrefslogtreecommitdiff
path: root/addons/mrp_subcontracting/models
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-10-09 02:08:17 +0200
committerChristophe Simonis <chs@odoo.com>2019-10-09 02:08:17 +0200
commitd74b4518052066446e2a1975a91ce53c745ca75a (patch)
treec08180f88a512d15e37fbec628931f02b3825f65 /addons/mrp_subcontracting/models
parentec162dd0cb5622ab6e56db1a63dab5f531a96f4a (diff)
parentf4105eb9c7010f8693e5d2fd20c0bd9d9cc2e483 (diff)
[MERGE] forward port branch 13.0 up to f4105eb9c70
Diffstat (limited to 'addons/mrp_subcontracting/models')
-rw-r--r--addons/mrp_subcontracting/models/stock_move.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/addons/mrp_subcontracting/models/stock_move.py b/addons/mrp_subcontracting/models/stock_move.py
index 9cb940781cf..06e762c6f1f 100644
--- a/addons/mrp_subcontracting/models/stock_move.py
+++ b/addons/mrp_subcontracting/models/stock_move.py
@@ -51,13 +51,12 @@ class StockMove(models.Model):
""" If the initial demand is updated then also update the linked
subcontract order to the new quantity.
"""
- res = super(StockMove, self).write(values)
if 'product_uom_qty' in values:
if self.env.context.get('cancel_backorder') is False:
- return res
+ return super(StockMove, self).write(values)
self.filtered(lambda m: m.is_subcontract and
- m.state not in ['draft', 'cancel', 'done'])._update_subcontract_order_qty()
- return res
+ m.state not in ['draft', 'cancel', 'done'])._update_subcontract_order_qty(values['product_uom_qty'])
+ return super(StockMove, self).write(values)
def action_show_details(self):
""" Open the produce wizard in order to register tracked components for
@@ -173,6 +172,11 @@ operations.""") % ('\n'.join(overprocessed_moves.mapped('product_id.display_name
vals['location_id'] = self.location_id.id
return vals
+ def _prepare_move_split_vals(self, qty):
+ vals = super(StockMove, self)._prepare_move_split_vals(qty)
+ vals['location_id'] = self.location_id.id
+ return vals
+
def _should_bypass_reservation(self):
""" If the move is subcontracted then ignore the reservation. """
should_bypass_reservation = super(StockMove, self)._should_bypass_reservation()
@@ -180,11 +184,12 @@ operations.""") % ('\n'.join(overprocessed_moves.mapped('product_id.display_name
return True
return should_bypass_reservation
- def _update_subcontract_order_qty(self):
+ def _update_subcontract_order_qty(self, quantity):
for move in self:
+ quantity_change = quantity - move.product_uom_qty
production = move.move_orig_ids.production_id
if production:
self.env['change.production.qty'].with_context(skip_activity=True).create({
'mo_id': production.id,
- 'product_qty': move.product_uom_qty
+ 'product_qty': production.product_uom_qty + quantity_change
}).change_prod_qty()