From f20dded993dcb42955bb79c21a61a17a34c7f7e8 Mon Sep 17 00:00:00 2001 From: yhu-odoo Date: Tue, 11 Aug 2020 19:17:17 +0000 Subject: [PATCH] [FIX] stock: inventory report form editable In inventory report, when groupby setted and no data, the create button will open a new form instead of create a new line. Since now our form view is not editable, no record can be created. In this commit, add a new editable form view to solve it. Task 2310494 PR #55910 closes odoo/odoo#57344 X-original-commit: 4a4e60c65049082855414941642dadce8b413475 Related: odoo/enterprise#13067 Signed-off-by: Arnold Moyaux --- addons/stock/models/stock_quant.py | 20 ++++++------- addons/stock/views/stock_quant_views.xml | 37 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index f8c95c5db46..1403f08a1ef 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -610,7 +610,7 @@ class StockQuant(models.Model): action = { 'name': _('Stock On Hand'), 'view_type': 'tree', - 'view_mode': 'list', + 'view_mode': 'list,form', 'res_model': 'stock.quant', 'type': 'ir.actions.act_window', 'context': ctx, @@ -624,22 +624,22 @@ class StockQuant(models.Model): if self._is_inventory_mode(): action['view_id'] = self.env.ref('stock.view_stock_quant_tree_editable').id + form_view = self.env.ref('stock.view_stock_quant_form_editable').id else: action['view_id'] = self.env.ref('stock.view_stock_quant_tree').id - # Enables form view in readonly list - action.update({ - 'view_mode': 'tree,form', - 'views': [ - (action['view_id'], 'list'), - (self.env.ref('stock.view_stock_quant_form').id, 'form'), - ], - }) + form_view = self.env.ref('stock.view_stock_quant_form').id + action.update({ + 'views': [ + (action['view_id'], 'list'), + (form_view, 'form'), + ], + }) if extend: action.update({ 'view_mode': 'tree,form,pivot,graph', 'views': [ (action['view_id'], 'list'), - (self.env.ref('stock.view_stock_quant_form').id, 'form'), + (form_view, 'form'), (self.env.ref('stock.view_stock_quant_pivot').id, 'pivot'), (self.env.ref('stock.stock_quant_view_graph').id, 'graph'), ], diff --git a/addons/stock/views/stock_quant_views.xml b/addons/stock/views/stock_quant_views.xml index ac9bf1e8993..170d943c627 100644 --- a/addons/stock/views/stock_quant_views.xml +++ b/addons/stock/views/stock_quant_views.xml @@ -35,6 +35,43 @@ + + stock.quant.form.editable + stock.quant + + +
+ + + + + + + + + + + + + + + +
+
+
+ stock.quant.form stock.quant