From dccc22293a3b8393e0573cab796fa1fa8a0b5603 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Fri, 22 May 2020 12:00:37 +0000 Subject: [PATCH] [IMP] stock: allow product creation in inventory adjustment Previous to this comment, creating new products during an inventory adjustment was not possible (within stock app, was possible within barcode app). Now it is possible to create new products within stock.inventory form 'product_ids'. Additionally the stock.inventory.line tree 'product_id' will also allow creation of new products only when there are no 'product_ids' assigned. By default these new products will have 'type'='product' (storable). Specification 2 of inventory onboarding improvements Task: 2220129 Related ENT PR: odoo/enterprise#10719 --- addons/stock/models/stock_inventory.py | 6 +++++- addons/stock/views/stock_inventory_views.xml | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) 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"/> -