diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index 9fa8f655e2a..09ad6056141 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -168,7 +168,6 @@ class Inventory(models.Model): self.ensure_one() action = { 'type': 'ir.actions.act_window', - 'views': [(self.env.ref('stock.stock_inventory_line_tree').id, 'tree')], 'view_mode': 'tree', 'name': _('Inventory Lines'), 'res_model': 'stock.inventory.line', @@ -190,8 +189,13 @@ class Inventory(models.Model): context['readonly_location_id'] = True if self.product_ids: + # no_create on product_id field + action['view_id'] = self.env.ref('stock.stock_inventory_line_tree_no_product_create').id if len(self.product_ids) == 1: context['default_product_id'] = self.product_ids[0].id + else: + # no product_ids => we're allowed to create new products in tree + action['view_id'] = self.env.ref('stock.stock_inventory_line_tree').id action['context'] = context action['domain'] = domain diff --git a/addons/stock/views/stock_inventory_views.xml b/addons/stock/views/stock_inventory_views.xml index e9bf7205d67..4167e5f30ce 100644 --- a/addons/stock/views/stock_inventory_views.xml +++ b/addons/stock/views/stock_inventory_views.xml @@ -13,7 +13,8 @@ - + stock.inventory.line.tree2 + stock.inventory.line + + primary + 1000 + + {'no_create': True} + + + stock.inventory.line.search stock.inventory.line @@ -180,7 +192,8 @@ widget="many2many_tags" force_save="1" groups="stock.group_stock_multi_locations"/> -