From 28f0700fdb5e065b09e785b37952dd6db754d7d3 Mon Sep 17 00:00:00 2001 From: JuMiSanAr Date: Wed, 6 Dec 2023 11:55:15 +0100 Subject: [PATCH] shopfloor_mobile_base: force nav item counter update --- shopfloor_mobile_base/static/wms/src/main.js | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/shopfloor_mobile_base/static/wms/src/main.js b/shopfloor_mobile_base/static/wms/src/main.js index 76379add59..78a7ddac25 100644 --- a/shopfloor_mobile_base/static/wms/src/main.js +++ b/shopfloor_mobile_base/static/wms/src/main.js @@ -77,6 +77,7 @@ new Vue({ global_state_key: "", loading: false, loading_msg_custom: "", + loadingMenu: false, appconfig: null, }; _.merge(data, config_registry.generare_data_keys()); @@ -122,6 +123,9 @@ new Vue({ }); event_hub.$emit("app:mounted", self, false); }, + beforeUpdate: function () { + this.loadMenu(true); + }, computed: { ...config_registry.generate_computed_properties(), app_info: function () { @@ -231,9 +235,20 @@ new Vue({ "SERVICE-CTX-PROFILE-ID": this.profile.id, }, }); - return odoo.call("menu").then(function (result) { - self.appmenu = result.data; - }); + if (!this.loadingMenu) { + // TODO: this is added to make sure to always have + // up-to-date counter in the navigation drawer items. + // It is not an ideal solution though, as it will be called + // whenever the component is updated (there's no easy way + // to refresh the counters only when needed, + // as each scenario has a different implementation). + // That being said, this call is very small so it's not that costly. + this.loadingMenu = true; + return odoo.call("menu").then((result) => { + self.appmenu = result.data; + this.loadingMenu = false; + }); + } }, login: function (evt, data) { evt.preventDefault();