summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authornie <nie@odoo.com>2021-01-20 15:36:27 +0000
committernie <nie@odoo.com>2021-02-01 11:06:07 +0000
commit9c9c4117ccc705dc47a67f659425de67e200542f (patch)
tree05283d969a65eb23b0577f891a0b2cf766d744c9 /addons
parentd29c70a14c67df9addb0f5bb070410f71c19cd0f (diff)
[FIX] board,stock: cannot add stock on hand report to dashboard
Steps: - Install Inventory and Dashboard - Go to Inventory > Reporting > Inventory Report - Click Favorites - Add to my Dashboard is missing - Open the Favorites dropdown again - Click Add to my Dashboard Bug: Error: Could not add filter to dashboard Explanation: This report action window is created dynamically by the server action `action_view_quants`. The `id` isn't present, but it's not needed to display the view. However, in order to create a dashboard item, the `id` of an action is required as seen here: https://github.com/odoo/odoo/blob/cfb5e6e82a773fee0342d5e0417bae4efeb7f0bb/addons/board/controllers/main.py#L16 This commit adds the ID of a new simple `ir.actions.act_window`. Reusing `product_template_open_quants` is not possible because, when refreshing the page, the view hasn't got any `active_ids`. The menu item only appears after reopening the Favorites dropdown because the frontend checks if the `id` of the action is present here: https://github.com/odoo/odoo/blob/cfb5e6e82a773fee0342d5e0417bae4efeb7f0bb/addons/board/static/src/js/add_to_board_menu.js#L35-L40 but re-renders it every time the dropdown is closed, no matter what: https://github.com/odoo/odoo/blob/cfb5e6e82a773fee0342d5e0417bae4efeb7f0bb/addons/board/static/src/js/add_to_board_menu.js#L50-L53 This commit also prevents the item from appearing after clicking multiple times on the button. opw:2426986 closes odoo/odoo#65302 X-original-commit: 1f4b7b23c8372c382a4e97fbc5052942de7c633e Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Signed-off-by: backspac <backspac@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/stock/i18n/stock.pot1
-rw-r--r--addons/stock/models/stock_quant.py4
-rw-r--r--addons/stock/views/stock_quant_views.xml5
3 files changed, 10 insertions, 0 deletions
diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot
index e1b6ff50fcc..57c920b4960 100644
--- a/addons/stock/i18n/stock.pot
+++ b/addons/stock/i18n/stock.pot
@@ -6028,6 +6028,7 @@ msgstr ""
#. module: stock
#: code:addons/stock/models/stock_quant.py:0
+#: model:ir.actions.act_window,name:stock.dashboard_open_quants
#, python-format
msgid "Stock On Hand"
msgstr ""
diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py
index 20aa77a628d..fca233509f2 100644
--- a/addons/stock/models/stock_quant.py
+++ b/addons/stock/models/stock_quant.py
@@ -625,6 +625,10 @@ class StockQuant(models.Model):
"""
}
+ target_action = self.env.ref('stock.dashboard_open_quants', False)
+ if target_action:
+ action['id'] = target_action.id
+
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
diff --git a/addons/stock/views/stock_quant_views.xml b/addons/stock/views/stock_quant_views.xml
index 1ae0fed8101..45128f812fd 100644
--- a/addons/stock/views/stock_quant_views.xml
+++ b/addons/stock/views/stock_quant_views.xml
@@ -207,6 +207,11 @@
</field>
</record>
+ <record model="ir.actions.act_window" id="dashboard_open_quants"> <!-- Used in dashboard -->
+ <field name="name">Stock On Hand</field>
+ <field name="context">{'search_default_internal_loc': 1, 'search_default_productgroup':1, 'search_default_locationgroup':1}</field>
+ <field name="res_model">stock.quant</field>
+ </record>
<record model="ir.actions.act_window" id="location_open_quants"> <!-- Used in location -->
<field name="context">{'search_default_productgroup': 1}</field>
<field name="domain">[('location_id', 'child_of', active_ids)]</field>