From 25946bd3b40098c2948ed324403d5f4df552901b Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Thu, 29 Aug 2019 09:39:15 +0000 Subject: [PATCH] [IMP] stock: empty inventory report Before this commit, if user tries to create a new record from a empty grouped editable list in 'Inventory Report', he/she will get the form view open which isn't editable. To avoid that, we remove the group filter if there is no quant, so user can create a new quant directly in the editable list. Task #2056651 closes odoo/odoo#36221 Signed-off-by: Simon Lejeune (sle) Co-authored-by: jip-odoo --- addons/stock/models/stock_quant.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 432c7c9a6db..b4c12f43149 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -575,7 +575,7 @@ class StockQuant(models.Model): 'view_mode': 'list', 'res_model': 'stock.quant', 'type': 'ir.actions.act_window', - 'context': self.env.context, + 'context': dict(self.env.context), 'domain': domain or [], 'help': """

No Stock On Hand

@@ -586,6 +586,16 @@ class StockQuant(models.Model): if self._is_inventory_mode(): action['view_id'] = self.env.ref('stock.view_stock_quant_tree_editable').id + # fixme: erase the following condition when it'll be possible to create a new record + # from a empty grouped editable list without go through the form view. + if not self.search_count([ + ('company_id', '=', self.env.company.id), + ('location_id.usage', 'in', ['internal', 'transit']) + ]): + action['context'].update({ + 'search_default_productgroup': 0, + 'search_default_locationgroup': 0 + }) else: action['view_id'] = self.env.ref('stock.view_stock_quant_tree').id # Enables form view in readonly list