From 9be5531f3e80ceb009d8f65abee22ec39010dc05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 2 Jun 2016 14:26:41 +0200 Subject: [PATCH] [FIX] web: fix actions in sidebar on second reload When the user visited a view for the second time, the extra actions in the sidebar were broken. The reason is that the sidebar code modified in place the fields_view information. Note: This was not a problem before, because the field_view_get call was done each time the view was loaded, but now it is cached. --- addons/web/static/src/js/widgets/sidebar.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/js/widgets/sidebar.js b/addons/web/static/src/js/widgets/sidebar.js index e2222526320..03997db6c36 100644 --- a/addons/web/static/src/js/widgets/sidebar.js +++ b/addons/web/static/src/js/widgets/sidebar.js @@ -103,13 +103,13 @@ var Sidebar = Widget.extend({ _.each(['print','action','relate'], function(type) { var items = toolbar[type]; if (items) { - for (var i = 0; i < items.length; i++) { - items[i] = { - label: items[i]['name'], - action: items[i], + var actions = _.map(items, function (item) { + return { + label: item.name, + action: item, }; - } - self.add_items(type=='print' ? 'print' : 'other', items); + }); + self.add_items(type === 'print' ? 'print' : 'other', actions); } }); }, @@ -218,4 +218,3 @@ var Sidebar = Widget.extend({ return Sidebar; }); -