[FIX] mrp_subcontracting: Error Message with partial delivery
Steps to reproduce:
- Create a product P with route 'Resupply subcontractor on an order'
- Let's consider a BOM for P with type 'Subcontracting'
- Create a PO with subcontractor set on that product and process with Qty > 1,
- Validate a receipt with partial Qty and no backorder
Bug:
An error was raised because no production_id was set when trying to create a mrp.product.produce
When function _action_done is called with cancel_backorder = True, the function _action_cancel is called on the new_move
with no backorder and it called the function _action_cancel defined on model stock.move in module mrp_subcontracting
This function called _action_cancel on the mrp.production record MP
And finally this function called action_cancel on model stock.move on all finish_moves and raw_moves of MP
This line unlink MP of finish_moves and raw_moves
move.move_dest_ids.write({'move_orig_ids': [(3, move.id, 0)]})
That's why production_id was not set
PS: In this way, we don't cancel a MO when it is still used by other moves.
opw:2322278
closes odoo/odoo#57346
X-original-commit: e4d22d390c8aa8edf757e36704a9e04b2b89f115
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
@@ -97,7 +97,10 @@ class StockMove(models.Model):
|
||||
def _action_cancel(self):
|
||||
for move in self:
|
||||
if move.is_subcontract:
|
||||
move.move_orig_ids.production_id._action_cancel()
|
||||
production = move.move_orig_ids.production_id
|
||||
moves = self.env.context.get('moves_todo')
|
||||
if not moves or production not in moves.move_orig_ids.production_id:
|
||||
production._action_cancel()
|
||||
return super()._action_cancel()
|
||||
|
||||
def _action_confirm(self, merge=True, merge_into=False):
|
||||
|
||||
@@ -1491,7 +1491,7 @@ class StockMove(models.Model):
|
||||
new_move = move._split(qty_split)
|
||||
move._unreserve_initial_demand(new_move)
|
||||
if cancel_backorder:
|
||||
self.env['stock.move'].browse(new_move)._action_cancel()
|
||||
self.env['stock.move'].browse(new_move).with_context(moves_todo=moves_todo)._action_cancel()
|
||||
moves_todo.mapped('move_line_ids').sorted()._action_done()
|
||||
# Check the consistency of the result packages; there should be an unique location across
|
||||
# the contained quants.
|
||||
|
||||
Reference in New Issue
Block a user