summaryrefslogtreecommitdiff
path: root/addons/web/controllers/main.py
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2016-02-09 15:43:06 +0100
committerYannick Tivisse <yti@odoo.com>2016-02-09 17:40:34 +0100
commit7db8f1ca3081b67afb9e31f1d3e65c6a35eec35f (patch)
tree199c7135181c2e379f54d18ad94f8256d17d2fba /addons/web/controllers/main.py
parent52193c4953f4108dee5eafef0dd40c1f466946ef (diff)
[IMP] web: remove rpc call on SwitchCompany widget loading
By setting the information returned by read_companies on the session information, we are able to remove the rpc call and the willStart method definition Also: Set a debounce on SwitchCompany widget to avoid multiple RPC
Diffstat (limited to 'addons/web/controllers/main.py')
-rw-r--r--addons/web/controllers/main.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index aff3afba674..b88a103a8df 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -710,6 +710,8 @@ class Session(http.Controller):
def session_info(self):
request.session.ensure_valid()
+ user = request.env.user
+ display_switch_company_menu = user.has_group('base.group_multi_company') and len(user.company_ids) > 1
return {
"session_id": request.session_id,
"uid": request.session.uid,
@@ -718,6 +720,7 @@ class Session(http.Controller):
"username": request.session.login,
"company_id": request.env.user.company_id.id if request.session.uid else None,
"partner_id": request.env.user.partner_id.id if request.session.uid and request.env.user.partner_id else None,
+ "user_companies": {'current_company': (user.company_id.id, user.company_id.name), 'allowed_companies': [(comp.id, comp.name) for comp in user.company_ids]} if display_switch_company_menu else False,
}
@http.route('/web/session/get_session_info', type='json', auth="none")