[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) <sle@openerp.com>
This commit is contained in:
@@ -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'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user