summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/chrome/menu.js
diff options
context:
space:
mode:
authorDavid Monjoie <dmo@odoo.com>2018-10-15 12:04:57 +0000
committerDavid Monjoie <dmo@odoo.com>2018-10-17 11:39:41 +0000
commit3ed45466f138ad442526123e17f20fa20bdb7259 (patch)
treef8b341726daf4e94b01b03bd5fa5f1b1e8c6d04e /addons/web/static/src/js/chrome/menu.js
parent44287eb719c07dc43b13bcd271c8b9c9e883fc7d (diff)
[FIX] web: fix menu app button when menu_id can't be inferred
There used to be no processing done at all when loading the client from an url missing a menu_id and from which the menu could not be inferred from the action_id. This resulted in the app name button in the menu being empty but still present and not bound to any action. Clicking on it triggered a traceback. This commit stops ignoring the case when the menu cannot be inferred from the action and hides the entire menu and submenus for this particular action. They will be restored when entering an action from which a proper menu can be inferred. closes odoo/odoo#27791
Diffstat (limited to 'addons/web/static/src/js/chrome/menu.js')
-rw-r--r--addons/web/static/src/js/chrome/menu.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/addons/web/static/src/js/chrome/menu.js b/addons/web/static/src/js/chrome/menu.js
index 6f9d5fe651c..8722724c9a6 100644
--- a/addons/web/static/src/js/chrome/menu.js
+++ b/addons/web/static/src/js/chrome/menu.js
@@ -81,6 +81,7 @@ var Menu = Widget.extend({
},
change_menu_section: function (primary_menu_id) {
if (!this.$menu_sections[primary_menu_id]) {
+ this._updateMenuBrand();
return; // unknown menu_id
}
@@ -95,7 +96,7 @@ var Menu = Widget.extend({
// Get back the application name
for (var i = 0; i < this.menu_data.children.length; i++) {
if (this.menu_data.children[i].id === primary_menu_id) {
- this.$menu_brand_placeholder.text(this.menu_data.children[i].name);
+ this._updateMenuBrand(this.menu_data.children[i].name);
break;
}
}
@@ -112,6 +113,22 @@ var Menu = Widget.extend({
previous_menu_id: this.current_secondary_menu || this.current_primary_menu,
});
},
+ /**
+ * Updates the name of the app in the menu to the value of brandName.
+ * If brandName is falsy, hides the menu and its sections.
+ *
+ * @private
+ * @param {brandName} string
+ */
+ _updateMenuBrand: function (brandName) {
+ if (brandName) {
+ this.$menu_brand_placeholder.text(brandName).show();
+ this.$section_placeholder.show();
+ } else {
+ this.$menu_brand_placeholder.hide()
+ this.$section_placeholder.hide();
+ }
+ },
_on_secondary_menu_click: function (menu_id, action_id) {
var self = this;