From 50220e6cb27249a8d2179a7d894cb0e97d30ecc7 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Thu, 20 Mar 2014 17:24:45 +0100 Subject: [PATCH] [ADD] hide the widget if the user has right on only one company. (following Arthru's remark) --- .../static/src/js/switch_company.js | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/web_easy_switch_company/static/src/js/switch_company.js b/web_easy_switch_company/static/src/js/switch_company.js index 279b5724..aac876e3 100644 --- a/web_easy_switch_company/static/src/js/switch_company.js +++ b/web_easy_switch_company/static/src/js/switch_company.js @@ -40,16 +40,22 @@ openerp.web_easy_switch_company = function (instance) { renderElement: function() { var self = this; this._super(); - this.$el.find('.easy_switch_company_company_item').on('click', function(ev) { - var company_id = $(ev.target).data("company-id"); - if (company_id != self.current_company_id){ - var func = '/web_easy_switch_company/switch/change_current_company'; - var param = {'company_id': company_id} - self.rpc(func, param).done(function(res) { - window.location.reload() - }); - } - }); + if (this.companies.length === 1) { + this.$el.hide(); + } + else{ + this.$el.show(); + this.$el.find('.easy_switch_company_company_item').on('click', function(ev) { + var company_id = $(ev.target).data("company-id"); + if (company_id != self.current_company_id){ + var func = '/web_easy_switch_company/switch/change_current_company'; + var param = {'company_id': company_id} + self.rpc(func, param).done(function(res) { + window.location.reload() + }); + } + }); + } }, /***********************************************************************