From ef30bd438ca80cfdcd6baad9b6db48f2c7d8282d Mon Sep 17 00:00:00 2001 From: Arnaud Baes Date: Mon, 9 Sep 2019 12:39:29 +0000 Subject: [PATCH] [FIX] stock: preserve context in scrap wizards Context was overwritten in the wizard warning for insufficient quantity when trying to scrap a componenent from a MO. This had a side-effect on the move creation of the scrap where the move was not linked to the MO, thus ignored by the cost analysis report. closes odoo/odoo#36563 Tasks: BugLogistics Signed-off-by: Simon Lejeune (sle) --- addons/stock/models/stock_scrap.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/stock/models/stock_scrap.py b/addons/stock/models/stock_scrap.py index 2e7d6eb021e..5ad0a297093 100644 --- a/addons/stock/models/stock_scrap.py +++ b/addons/stock/models/stock_scrap.py @@ -166,17 +166,19 @@ class StockScrap(models.Model): if float_compare(available_qty, scrap_qty, precision_digits=precision) >= 0: return self.do_scrap() else: + ctx = dict(self.env.context) + ctx.update({ + 'default_product_id': self.product_id.id, + 'default_location_id': self.location_id.id, + 'default_scrap_id': self.id + }) return { 'name': _('Insufficient Quantity'), 'view_mode': 'form', 'res_model': 'stock.warn.insufficient.qty.scrap', 'view_id': self.env.ref('stock.stock_warn_insufficient_qty_scrap_form_view').id, 'type': 'ir.actions.act_window', - 'context': { - 'default_product_id': self.product_id.id, - 'default_location_id': self.location_id.id, - 'default_scrap_id': self.id - }, + 'context': ctx, 'target': 'new' }