[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
This commit is contained in:
Simon Lejeune
2018-06-11 16:56:55 +02:00
parent aad104621c
commit cea38a8ea9
+3 -1
View File
@@ -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',