mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[FIX] base_user_role_profile: remove multicompany functionality
This commit is contained in:
@@ -1,85 +0,0 @@
|
||||
odoo.define("web.SwitchProfileMenu", function (require) {
|
||||
"use strict";
|
||||
|
||||
var config = require("web.config");
|
||||
var core = require("web.core");
|
||||
var session = require("web.session");
|
||||
var SystrayMenu = require("web.SystrayMenu");
|
||||
var Widget = require("web.Widget");
|
||||
var _t = core._t;
|
||||
|
||||
var SwitchProfileMenu = Widget.extend({
|
||||
template: "SwitchProfileMenu",
|
||||
events: {
|
||||
"click .dropdown-item[data-menu]": "_onClick",
|
||||
},
|
||||
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this.isMobile = config.device.isMobile;
|
||||
this._onClick = _.debounce(this._onClick, 1500, true);
|
||||
},
|
||||
|
||||
willStart: function () {
|
||||
return session.user_profiles ? this._super() : $.Deferred().reject();
|
||||
},
|
||||
|
||||
start: function () {
|
||||
var profilesList = "";
|
||||
if (this.isMobile) {
|
||||
profilesList =
|
||||
'<li class="bg-info">' +
|
||||
_t("Tap on the list to change profile") +
|
||||
"</li>";
|
||||
} else {
|
||||
this.$(".oe_topbar_name").text(
|
||||
session.user_profiles.current_profile[1]
|
||||
);
|
||||
}
|
||||
_.each(session.user_profiles.allowed_profiles, function (profile) {
|
||||
var a = "";
|
||||
if (profile[0] == session.user_profiles.current_profile[0]) {
|
||||
a = '<i class="fa fa-check mr8"></i>';
|
||||
} else {
|
||||
a = '<span style="margin-right: 24px;"/>';
|
||||
}
|
||||
profilesList +=
|
||||
'<a role="menuitem" href="#" class="dropdown-item" data-menu="profile" data-profile-id="' +
|
||||
profile[0] +
|
||||
'">' +
|
||||
a +
|
||||
profile[1] +
|
||||
"</a>";
|
||||
});
|
||||
this.$(".dropdown-menu").html(profilesList);
|
||||
return this._super();
|
||||
},
|
||||
|
||||
_onClick: function (ev) {
|
||||
var self = this;
|
||||
ev.preventDefault();
|
||||
var profileID = $(ev.currentTarget).data("profile-id");
|
||||
// We use this instead of the location.reload() because permissions change
|
||||
// and we might land on a menu that we don't have permissions for. Thus it
|
||||
// is cleaner to reload any root menu
|
||||
this._rpc({
|
||||
model: "res.users",
|
||||
method: "action_profile_change",
|
||||
args: [
|
||||
[session.uid],
|
||||
{
|
||||
profile_id: profileID,
|
||||
},
|
||||
],
|
||||
}).done(function (result) {
|
||||
self.trigger_up("do_action", {
|
||||
action: result,
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
SystrayMenu.Items.push(SwitchProfileMenu);
|
||||
|
||||
return SwitchProfileMenu;
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="SwitchProfileMenu">
|
||||
<li class="o_switch_profile_menu">
|
||||
<a
|
||||
role="button"
|
||||
class="dropdown-toggle"
|
||||
data-toggle="dropdown"
|
||||
aria-expanded="false"
|
||||
href="#"
|
||||
aria-label="Dropdown menu"
|
||||
title="Dropdown menu"
|
||||
>
|
||||
<span
|
||||
t-attf-class="#{widget.isMobile ? 'fa fa-building-o' : 'oe_topbar_name'}"
|
||||
/>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right" role="menu" />
|
||||
</li>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
Reference in New Issue
Block a user