diff options
| author | Goffin Simon <sig@odoo.com> | 2020-09-07 14:30:43 +0000 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2020-09-09 10:02:09 +0000 |
| commit | 6decc32a889b46947db6dd4d42ef995935894a2a (patch) | |
| tree | 9712b9b3436fed087b814ebdb9200432db36f3c7 /addons/mrp_subcontracting | |
| parent | 57d857d091fd8657c4c5676da6959403f2302116 (diff) | |
[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#57340
X-original-commit: e4d22d390c8aa8edf757e36704a9e04b2b89f115
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Diffstat (limited to 'addons/mrp_subcontracting')
| -rw-r--r-- | addons/mrp_subcontracting/models/stock_move.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/mrp_subcontracting/models/stock_move.py b/addons/mrp_subcontracting/models/stock_move.py index 6854e8f0bff..32817a4ca8b 100644 --- a/addons/mrp_subcontracting/models/stock_move.py +++ b/addons/mrp_subcontracting/models/stock_move.py @@ -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): |
