[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
This commit is contained in:
Nicolas Martinelli
2017-01-23 09:19:49 +01:00
parent 4169049263
commit 68dd9bdb0a
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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')
+1 -1
View File
@@ -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,