mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[MIG] V13 properties menu
This commit is contained in:
27
pms/static/src/js/inherited_abstract_web_client.js
Normal file
27
pms/static/src/js/inherited_abstract_web_client.js
Normal 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);
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user