From 68dd9bdb0a5eb2eaff897cb652e701e0ee03bdd1 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 20 Jan 2017 16:24:09 +0100 Subject: [PATCH] [FIX] board: prevent crash if no action If the user tries to save on the dashboard a view which was not open through an existing action, the call to method `add_to_dashboard` crashes because of incorrect arguments (`action_id` is undefined in JS). This is for example the case when trying to save an "Inventory at Date" in the dashboard (will be fixed in a subsequent commit). opw-703649 --- addons/board/controllers.py | 2 +- addons/board/static/src/js/dashboard.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/board/controllers.py b/addons/board/controllers.py index 6eb0890ea46..f0486f59736 100644 --- a/addons/board/controllers.py +++ b/addons/board/controllers.py @@ -13,7 +13,7 @@ class Board(Controller): # Retrieve the 'My Dashboard' action from its xmlid action = request.env['ir.model.data'].get_object('board', 'open_board_my_dash_action') - if action and action['res_model'] == 'board.board' and action['views'][0][1] == 'form': + if action and action['res_model'] == 'board.board' and action['views'][0][1] == 'form' and action_id: # Maybe should check the content instead of model board.board ? view_id = action['views'][0][0] board = request.env[action['res_model']].fields_view_get(view_id, 'form') diff --git a/addons/board/static/src/js/dashboard.js b/addons/board/static/src/js/dashboard.js index 1d543f1216c..10818ef20a5 100644 --- a/addons/board/static/src/js/dashboard.js +++ b/addons/board/static/src/js/dashboard.js @@ -405,7 +405,7 @@ FavoriteMenu.include({ name = self.$add_dashboard_input.val(); return self.rpc('/board/add_to_dashboard', { - action_id: self.action_id, + action_id: self.action_id || false, context_to_save: c, domain: d, view_mode: self.view_manager.active_view.type,