diff --git a/placeholder/__init__.py b/placeholder/__init__.py deleted file mode 100644 index 9dd152f93..000000000 --- a/placeholder/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2014 Therp BV (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## diff --git a/placeholder/__openerp__.py b/placeholder/__openerp__.py deleted file mode 100644 index 473029a19..000000000 --- a/placeholder/__openerp__.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2014 Therp BV (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## -{ - "name": "placeholder", - "version": "1.0", - "author": "Therp BV", - "license": "AGPL-3", - "complexity": "normal", - "description": """ -This is a placeholder module because odoo checks if an addons path contains -addons at all. This makes travis fail, so we need this until the first addon is -ported. - -Please remove as soon as you commit your first port! - """, - "category": "", - "depends": [ - ], - "data": [ - ], - "js": [ - ], - "css": [ - ], - "qweb": [ - ], - "auto_install": False, - "installable": True, - "application": False, - "external_dependencies": { - 'python': [], - }, -} diff --git a/__unported__/web_easy_switch_company/__init__.py b/web_easy_switch_company/__init__.py similarity index 99% rename from __unported__/web_easy_switch_company/__init__.py rename to web_easy_switch_company/__init__.py index f99517594..546a4603d 100644 --- a/__unported__/web_easy_switch_company/__init__.py +++ b/web_easy_switch_company/__init__.py @@ -19,6 +19,5 @@ # along with this program. If not, see . # ############################################################################## - from . import model from . import controllers diff --git a/__unported__/web_easy_switch_company/__openerp__.py b/web_easy_switch_company/__openerp__.py similarity index 98% rename from __unported__/web_easy_switch_company/__openerp__.py rename to web_easy_switch_company/__openerp__.py index 81310f604..05f0ea9dc 100644 --- a/__unported__/web_easy_switch_company/__openerp__.py +++ b/web_easy_switch_company/__openerp__.py @@ -66,6 +66,6 @@ Copyright, Author and Licence: 'qweb': [ 'static/src/xml/switch_company.xml', ], - 'installable': False, + 'installable': True, 'auto_install': False, } diff --git a/__unported__/web_easy_switch_company/controllers/__init__.py b/web_easy_switch_company/controllers/__init__.py similarity index 100% rename from __unported__/web_easy_switch_company/controllers/__init__.py rename to web_easy_switch_company/controllers/__init__.py diff --git a/__unported__/web_easy_switch_company/controllers/main.py b/web_easy_switch_company/controllers/main.py similarity index 60% rename from __unported__/web_easy_switch_company/controllers/main.py rename to web_easy_switch_company/controllers/main.py index 40387f904..346d7eb7a 100644 --- a/__unported__/web_easy_switch_company/controllers/main.py +++ b/web_easy_switch_company/controllers/main.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -############################################################################## +# ############################################################################# # # Web Easy Switch Company module for OpenERP # Copyright (C) 2014 GRAP (http://www.grap.coop) @@ -18,14 +18,17 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## - +############################################################################# import openerp +import openerp.http as http +from openerp.http import request -class WebEasySwitchCompanyController(openerp.addons.web.http.Controller): - _cp_path = '/web_easy_switch_company/switch' - - @openerp.addons.web.http.jsonrequest - def change_current_company(self, req, company_id): - req.session.model('res.users').change_current_company(company_id) +class WebEasySwitchCompanyController(http.Controller): + @http.route('/web_easy_switch_company/switch/change_current_company', type='json', auth='none') + def change_current_company(self, company_id): + registry = openerp.modules.registry.RegistryManager.get(request.session.db) + uid = request.session.uid + with registry.cursor() as cr: + res = registry.get("res.users").change_current_company(cr, uid, company_id) + return res diff --git a/__unported__/web_easy_switch_company/model/__init__.py b/web_easy_switch_company/model/__init__.py similarity index 100% rename from __unported__/web_easy_switch_company/model/__init__.py rename to web_easy_switch_company/model/__init__.py diff --git a/__unported__/web_easy_switch_company/model/res_company.py b/web_easy_switch_company/model/res_company.py similarity index 100% rename from __unported__/web_easy_switch_company/model/res_company.py rename to web_easy_switch_company/model/res_company.py diff --git a/__unported__/web_easy_switch_company/model/res_users.py b/web_easy_switch_company/model/res_users.py similarity index 93% rename from __unported__/web_easy_switch_company/model/res_users.py rename to web_easy_switch_company/model/res_users.py index 68c6fdfa6..c2ab2c13e 100644 --- a/__unported__/web_easy_switch_company/model/res_users.py +++ b/web_easy_switch_company/model/res_users.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -############################################################################## +# ############################################################################# # # Web Easy Switch Company module for OpenERP # Copyright (C) 2014 GRAP (http://www.grap.coop) diff --git a/__unported__/web_easy_switch_company/static/src/img/icon.png b/web_easy_switch_company/static/description/icon.png similarity index 100% rename from __unported__/web_easy_switch_company/static/src/img/icon.png rename to web_easy_switch_company/static/description/icon.png diff --git a/__unported__/web_easy_switch_company/static/src/img/selection-off.png b/web_easy_switch_company/static/description/selection-off.png similarity index 100% rename from __unported__/web_easy_switch_company/static/src/img/selection-off.png rename to web_easy_switch_company/static/description/selection-off.png diff --git a/__unported__/web_easy_switch_company/static/src/img/selection-on.png b/web_easy_switch_company/static/description/selection-on.png similarity index 100% rename from __unported__/web_easy_switch_company/static/src/img/selection-on.png rename to web_easy_switch_company/static/description/selection-on.png diff --git a/__unported__/web_easy_switch_company/static/src/js/switch_company.js b/web_easy_switch_company/static/src/js/switch_company.js similarity index 95% rename from __unported__/web_easy_switch_company/static/src/js/switch_company.js rename to web_easy_switch_company/static/src/js/switch_company.js index fd25d200b..894d3d991 100644 --- a/__unported__/web_easy_switch_company/static/src/js/switch_company.js +++ b/web_easy_switch_company/static/src/js/switch_company.js @@ -62,6 +62,8 @@ openerp.web_easy_switch_company = function (instance) { 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} @@ -102,8 +104,8 @@ openerp.web_easy_switch_company = function (instance) { // Note: calling res.company.name_search with // user_preference=True in the context does // not work either. - new instance.web.Model('res.users').call('fields_view_get',{context:{'form_view_ref':'base.view_users_form_simple_modif'}}).then(function(res){ - var res_company = res.fields.company_id.selection; + new instance.web.Model('res.company').call('name_search',{context:{'user_preference':'True'}}).then(function(res){ + var res_company = res; for ( var i=0 ; i < res_company.length; i++) { var logo_topbar, logo_state; // TODO: fetching the logo of other companies fails with the @@ -116,10 +118,10 @@ openerp.web_easy_switch_company = function (instance) { id: res_company[i][0] }); if (res_company[i][0] == self.current_company_id){ - logo_state = '/web_easy_switch_company/static/src/img/selection-on.png'; + logo_state = '/web_easy_switch_company/static/description/selection-on.png'; } else{ - logo_state = '/web_easy_switch_company/static/src/img/selection-off.png'; + logo_state = '/web_easy_switch_company/static/description/selection-off.png'; } self.companies.push({ id: res_company[i][0], @@ -145,7 +147,7 @@ openerp.web_easy_switch_company = function (instance) { this._super(parent); var switch_button = new instance.web.SwitchCompanyWidget(); switch_button.appendTo(instance.webclient.$el.find('.oe_systray')); - }, + } }); diff --git a/__unported__/web_easy_switch_company/static/src/xml/switch_company.xml b/web_easy_switch_company/static/src/xml/switch_company.xml similarity index 58% rename from __unported__/web_easy_switch_company/static/src/xml/switch_company.xml rename to web_easy_switch_company/static/src/xml/switch_company.xml index 9f540b239..1ffb12b20 100644 --- a/__unported__/web_easy_switch_company/static/src/xml/switch_company.xml +++ b/web_easy_switch_company/static/src/xml/switch_company.xml @@ -21,24 +21,29 @@ diff --git a/__unported__/web_easy_switch_company/view/res_users_view.xml b/web_easy_switch_company/view/res_users_view.xml similarity index 67% rename from __unported__/web_easy_switch_company/view/res_users_view.xml rename to web_easy_switch_company/view/res_users_view.xml index 571c28de5..e16259edd 100644 --- a/__unported__/web_easy_switch_company/view/res_users_view.xml +++ b/web_easy_switch_company/view/res_users_view.xml @@ -13,5 +13,12 @@ + + +