From f92601704ee4c47f5852c7d576fb4ca74c3e2b47 Mon Sep 17 00:00:00 2001 From: amoyaux Date: Thu, 28 Sep 2017 13:33:52 +0200 Subject: [PATCH] [REF] stock: scrap display product on stock move Previously a user was only able to scrap reserved product (products that have a stock move line associated on the picking). With this commit the user can scrap any product that has a move on the picking. --- addons/stock/models/stock_picking.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 1bb3a682b03..3aa0828bd86 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -805,6 +805,10 @@ class Picking(models.Model): def button_scrap(self): self.ensure_one() + 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'): + products |= move.product_id return { 'name': _('Scrap'), 'view_type': 'form', @@ -812,7 +816,7 @@ class Picking(models.Model): 'res_model': 'stock.scrap', 'view_id': self.env.ref('stock.stock_scrap_form_view2').id, 'type': 'ir.actions.act_window', - 'context': {'default_picking_id': self.id, 'product_ids': self.move_line_ids.mapped('product_id').ids}, + 'context': {'default_picking_id': self.id, 'product_ids': products.ids}, 'target': 'new', }