summaryrefslogtreecommitdiff
path: root/addons/mrp_subcontracting/models
diff options
context:
space:
mode:
authorArnold Moyaux <arm@odoo.com>2020-01-02 09:42:12 +0000
committerArnold Moyaux <arm@odoo.com>2020-01-02 18:11:33 +0000
commitea340afafa90bc6bc421a83d3ae1977efac808f4 (patch)
treea17e33a24b2568b82a9cb3231cb8dfbde41fffec /addons/mrp_subcontracting/models
parent858c9ec3945a40961b5e18aa1ead725a3a1fde45 (diff)
[FIX] mrp_subcontracting: cancel a PO should cancel delivery
When subcontracting a product via a purchase order and not a simple receipt. Then the cancelation of the receipt will not only cancel the receipt of the finished product but not the delivery for the components. It happens because button_cancel on purchase order will call _action_cancel the stock.move linked to purchase order line. It will not call action_cancel on the stock.picking. However the part responsible for the cancelation of components delivery is in the stock.picking action_cancel method. Move the stock.picking action_cancel logic in the stock.move _action_cancel method since it's always call for both usecase. Fixes #42551 closes odoo/odoo#42653 X-original-commit: 841305f271411c3a67af271ac09da9ce0922f100 Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
Diffstat (limited to 'addons/mrp_subcontracting/models')
-rw-r--r--addons/mrp_subcontracting/models/stock_move.py6
-rw-r--r--addons/mrp_subcontracting/models/stock_picking.py5
2 files changed, 6 insertions, 5 deletions
diff --git a/addons/mrp_subcontracting/models/stock_move.py b/addons/mrp_subcontracting/models/stock_move.py
index 21884eb269e..a6d8a61dd91 100644
--- a/addons/mrp_subcontracting/models/stock_move.py
+++ b/addons/mrp_subcontracting/models/stock_move.py
@@ -93,6 +93,12 @@ class StockMove(models.Model):
'domain': [('id', 'in', moves.ids)],
}
+ def _action_cancel(self):
+ for move in self:
+ if move.is_subcontract:
+ move.move_orig_ids.production_id._action_cancel()
+ return super()._action_cancel()
+
def _action_confirm(self, merge=True, merge_into=False):
subcontract_details_per_picking = defaultdict(list)
for move in self:
diff --git a/addons/mrp_subcontracting/models/stock_picking.py b/addons/mrp_subcontracting/models/stock_picking.py
index e3040792084..29c44aec51b 100644
--- a/addons/mrp_subcontracting/models/stock_picking.py
+++ b/addons/mrp_subcontracting/models/stock_picking.py
@@ -36,11 +36,6 @@ class StockPicking(models.Model):
# -------------------------------------------------------------------------
# Action methods
# -------------------------------------------------------------------------
- def action_cancel(self):
- for picking in self:
- picking._get_subcontracted_productions()._action_cancel()
- return super(StockPicking, self).action_cancel()
-
def _action_done(self):
res = super(StockPicking, self)._action_done()
productions = self.env['mrp.production']