From 657e6aba7762fcc6729077187d28fe4612ec48d9 Mon Sep 17 00:00:00 2001 From: Pablo Quesada Barriuso Date: Tue, 25 Aug 2020 22:43:50 +0200 Subject: [PATCH] [MIG] V13 properties menu --- .../src/js/inherited_abstract_web_client.js | 27 +++++++++++++++++++ pms/views/inherited_webclient_templates.xml | 1 + 2 files changed, 28 insertions(+) create mode 100644 pms/static/src/js/inherited_abstract_web_client.js diff --git a/pms/static/src/js/inherited_abstract_web_client.js b/pms/static/src/js/inherited_abstract_web_client.js new file mode 100644 index 000000000..c331e0276 --- /dev/null +++ b/pms/static/src/js/inherited_abstract_web_client.js @@ -0,0 +1,27 @@ +odoo.define('pms.AbstractWebClient', function (require) { + "use strict"; + + var AbstractWebClient = require('web.AbstractWebClient'); + var session = require('web.session'); + + return AbstractWebClient.include({ + start: function () { + var state = $.bbq.getState(); + var current_pms_property_id = session.user_pms_properties.current_pms_property[0] + if (!state.pms_pids) { + state.pms_pids = utils.get_cookie('pms_pids') !== null ? utils.get_cookie('pms_pids') : String(current_pms_property_id); + } + var statePmsPropertyIDS = _.map(state.pms_pids.split(','), function (pms_pid) { return parseInt(pms_pid) }); + var userPmsPropertyIDS = _.map(session.user_pms_properties.allowed_pms_properties, function(pms_property) {return pms_property[0]}); + // Check that the user has access to all the companies + if (!_.isEmpty(_.difference(statePmsPropertyIDS, userPmsPropertyIDS))) { + state.pms_pids = String(current_pms_property_id); + statePmsPropertyIDS = [current_pms_property_id] + } + session.user_context.allowed_pms_property_ids = statePmsPropertyIDS; + + return this._super.apply(this, arguments); + + }, + }); +}); \ No newline at end of file diff --git a/pms/views/inherited_webclient_templates.xml b/pms/views/inherited_webclient_templates.xml index 95295e740..e625c8d59 100644 --- a/pms/views/inherited_webclient_templates.xml +++ b/pms/views/inherited_webclient_templates.xml @@ -4,6 +4,7 @@