[MIG] V13 properties menu

This commit is contained in:
Pablo Quesada Barriuso
2020-08-25 22:43:50 +02:00
parent bd13457ee9
commit 657e6aba77
2 changed files with 28 additions and 0 deletions

View File

@@ -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);
},
});
});

View File

@@ -4,6 +4,7 @@
<template id="assets_backend" name="pms assets" inherit_id="web.assets_backend">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/pms/static/src/js/session.js"></script>
<script type="text/javascript" src="/pms/static/src/js/inherited_abstract_web_client.js"></script>
<script type="text/javascript" src="/pms/static/src/js/widgets/switch_property_menu.js"></script>
</xpath>
</template>