From cea38a8ea9239d3af7f9e6114cbed249f6e5c16f Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Mon, 11 Jun 2018 16:53:09 +0200 Subject: [PATCH] [REF] stock: scrap action Complete the scrap action so that it doesn't crash for some reason when called from a do_action in javascript. task-183075 --- addons/stock/models/stock_picking.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index f74ac493baa..c60591d8e4f 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -1005,6 +1005,7 @@ class Picking(models.Model): def button_scrap(self): self.ensure_one() + view = self.env.ref('stock.stock_scrap_form_view2') products = self.env['product.product'] for move in self.move_lines: if move.state not in ('draft', 'cancel') and move.product_id.type in ('product', 'consu'): @@ -1014,7 +1015,8 @@ class Picking(models.Model): 'view_type': 'form', 'view_mode': 'form', 'res_model': 'stock.scrap', - 'view_id': self.env.ref('stock.stock_scrap_form_view2').id, + 'view_id': view.id, + 'views': [(view.id, 'form')], 'type': 'ir.actions.act_window', 'context': {'default_picking_id': self.id, 'product_ids': products.ids}, 'target': 'new',