From e678e3e0809a9d188ac683be1f1a69bb93d6dd78 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Tue, 17 Nov 2015 18:26:55 +0100 Subject: [PATCH 1/7] fix: migrate to 9.0 - Use new UserMenu include method - Works with Community and enterprise --- web_easy_switch_company/__openerp__.py | 5 +- .../static/src/js/switch_company.js | 53 +++++++++---------- .../static/src/xml/switch_company.xml | 1 - 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/web_easy_switch_company/__openerp__.py b/web_easy_switch_company/__openerp__.py index cad9fa1f..ebe44568 100644 --- a/web_easy_switch_company/__openerp__.py +++ b/web_easy_switch_company/__openerp__.py @@ -22,7 +22,7 @@ { 'name': 'Multicompany - Easy Switch Company', - 'version': '8.0.1.0.0', + 'version': '9.0.1.0.0', 'category': 'web', 'description': """ Add menu to allow user to switch to another company more easily @@ -50,6 +50,7 @@ Copyright, Author and Licence: ------------------------------ * Copyright: 2014, Groupement Régional Alimentaire de Proximité; * Author: Sylvain LE GAL (https://twitter.com/legalsylvain); + * Contributor: Nicolas JEUDY (https://github.com/njeudy); * Licence: AGPL-3 (http://www.gnu.org/licenses/)""", 'author': "GRAP,Odoo Community Association (OCA)", 'website': 'http://www.grap.coop', @@ -63,6 +64,6 @@ Copyright, Author and Licence: 'qweb': [ 'static/src/xml/switch_company.xml', ], - 'installable': False, + 'installable': True, 'auto_install': False, } 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 894d3d99..216adf0f 100644 --- a/web_easy_switch_company/static/src/js/switch_company.js +++ b/web_easy_switch_company/static/src/js/switch_company.js @@ -1,7 +1,8 @@ /****************************************************************************** Web Easy Switch Company module for OpenERP - Copyright (C) 2014 GRAP (http://www.grap.coop) + Copyright (C) 2014-2015 GRAP (http://www.grap.coop) @author Sylvain LE GAL (https://twitter.com/legalsylvain) + @contributor Nicolas JEUDY (https://github.com/njeudy) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -17,18 +18,27 @@ along with this program. If not, see . ******************************************************************************/ -openerp.web_easy_switch_company = function (instance) { +odoo.define('web.web_easy_switch_company',function (require) { + + "use strict"; + + var core = require('web.core'); + var Widget = require('web.Widget'); + var UserMenu = require('web.UserMenu'); + var SystrayMenu = require('web.SystrayMenu'); + var web_client = require('web.web_client'); + var Model = require('web.Model'); /*************************************************************************** - Create an new 'SwitchCompanyWidget' widget that allow users to switch + Create an new 'SwitchCompanyWidget' widget that allow users to switch from a company to another more easily. ***************************************************************************/ - instance.web.SwitchCompanyWidget = instance.web.Widget.extend({ + var SwitchCompanyWidget = Widget.extend({ template:'web_easy_switch_company.SwitchCompanyWidget', /*********************************************************************** - Overload section + Overload section ***********************************************************************/ /** @@ -77,14 +87,14 @@ openerp.web_easy_switch_company = function (instance) { /*********************************************************************** - Custom section + Custom section ***********************************************************************/ /** * helper function to load data from the server */ _fetch: function(model, fields, domain, ctx){ - return new instance.web.Model(model).query(fields).filter(domain).context(ctx).all(); + return new Model(model).query(fields).filter(domain).context(ctx).all(); }, /** @@ -94,17 +104,18 @@ openerp.web_easy_switch_company = function (instance) { _load_data: function(){ var self = this; // Request for current users information + this._fetch('res.users',['company_id'],[['id','=',this.session.uid]]).then(function(res_users){ self.current_company_id = res_users[0].company_id[0]; self.current_company_name = res_users[0].company_id[1]; // Request for other companies // We have to go through fields_view_get to emulate the - // exact (exotic) behavior of the user preferences form in + // exact (exotic) behavior of the user preferences form in // fetching the allowed companies wrt record rules. - // Note: calling res.company.name_search with - // user_preference=True in the context does + // Note: calling res.company.name_search with + // user_preference=True in the context does // not work either. - new instance.web.Model('res.company').call('name_search',{context:{'user_preference':'True'}}).then(function(res){ + new 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; @@ -113,8 +124,8 @@ openerp.web_easy_switch_company = function (instance) { // probably remove the logos from the menu :( logo_topbar = self.session.url( '/web/binary/image', { - model:'res.company', - field: 'logo_topbar', + model:'res.company', + field: 'logo_topbar', id: res_company[i][0] }); if (res_company[i][0] == self.current_company_id){ @@ -138,18 +149,6 @@ openerp.web_easy_switch_company = function (instance) { }); - /*************************************************************************** - Extend 'UserMenu' Widget to insert a 'SwitchCompanyWidget' widget. - ***************************************************************************/ - instance.web.UserMenu = instance.web.UserMenu.extend({ - - init: function(parent) { - this._super(parent); - var switch_button = new instance.web.SwitchCompanyWidget(); - switch_button.appendTo(instance.webclient.$el.find('.oe_systray')); - } - - }); - -}; +SystrayMenu.Items.push(SwitchCompanyWidget); +}); diff --git a/web_easy_switch_company/static/src/xml/switch_company.xml b/web_easy_switch_company/static/src/xml/switch_company.xml index 1ffb12b2..c34c9db1 100644 --- a/web_easy_switch_company/static/src/xml/switch_company.xml +++ b/web_easy_switch_company/static/src/xml/switch_company.xml @@ -47,4 +47,3 @@ - From 4281511d31b80a66db2b6fcd4ee5ef4c65a1dbd5 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Tue, 17 Nov 2015 18:34:28 +0100 Subject: [PATCH 2/7] fix: update README.md for migration state --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9177d8d6..25ff19e0 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ addon | version | summary [web_dashboard_tile](web_dashboard_tile/) | 8.0.1.0.0 (unported) | Add Tiles to Dashboard [web_dialog_size](web_dialog_size/) | 8.0.0.1.0 (unported) | A module that lets the user expand a dialog box to the full screen width. [web_dom_model_classes](web_dom_model_classes/) | 8.0.1.0.0 (unported) | Allows small UI changes with simple CSS -[web_easy_switch_company](web_easy_switch_company/) | 8.0.1.0.0 (unported) | Multicompany - Easy Switch Company +[web_easy_switch_company](web_easy_switch_company/) | 9.0.1.0.0 | Multicompany - Easy Switch Company [web_environment_ribbon](web_environment_ribbon/) | 8.0.0.1.0 (unported) | Web Environment Ribbon [web_export_view](web_export_view/) | 8.0.1.2.0 (unported) | Export Current View [web_graph_improved](web_graph_improved/) | 8.0.0.1.0 (unported) | Improves graph views. From 0fe39e8dc97a3bc6deb41aca1b32e16f7d318b0a Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Tue, 29 Dec 2015 09:49:51 +0100 Subject: [PATCH 3/7] new: Add correct README.txt and rebase: - Rebase to latest 9.0 branch - Modify README without legal claim - Test an check on latest odoo community and enterprise 9.0. --- web_easy_switch_company/README.rst | 88 ++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 web_easy_switch_company/README.rst diff --git a/web_easy_switch_company/README.rst b/web_easy_switch_company/README.rst new file mode 100644 index 00000000..52d867dd --- /dev/null +++ b/web_easy_switch_company/README.rst @@ -0,0 +1,88 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================= +web_easy_switch_company +======================= + +This module extend web backend and allow user to switch to another company more easyly. + +Configuration +============= + +To configure this module, you need to: + +* Enable multi company in your odoo instance +* Add your user in at least 2 company, and you will see the switch at the upper right corner + +Usage +===== + +Functionality: +-------------- + * Add a new menu in the top bar to switch to another company more easily; + * Remove the old behaviour to switch company; + +Documentations: +--------------- + * Video : http://www.youtube.com/watch?v=Cpm6dg-IEQQ + +Technical information: +---------------------- + * Create a field function 'logo_topbar' in res_company to have a good""" + """resized logo; + +Limits: +------- + * It would be interesting to show the structure of the companies; + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/162/9.0 + + +Known issues / Roadmap +====================== + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed `feedback +`_. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Copyright: 2014, Groupement Régional Alimentaire de Proximité; +* Author: Sylvain LE GAL (https://twitter.com/legalsylvain); +* Contributor: Nicolas JEUDY - Sudokeys (https://github.com/njeudy) + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. From d00e0808f6eb1851be892197d478f593e25aa77e Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Tue, 12 Jan 2016 10:08:04 +0100 Subject: [PATCH 4/7] fix: remove unneeded dependency --- web_easy_switch_company/static/src/js/switch_company.js | 2 -- 1 file changed, 2 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 216adf0f..8797720a 100644 --- a/web_easy_switch_company/static/src/js/switch_company.js +++ b/web_easy_switch_company/static/src/js/switch_company.js @@ -22,9 +22,7 @@ odoo.define('web.web_easy_switch_company',function (require) { "use strict"; - var core = require('web.core'); var Widget = require('web.Widget'); - var UserMenu = require('web.UserMenu'); var SystrayMenu = require('web.SystrayMenu'); var web_client = require('web.web_client'); var Model = require('web.Model'); From dcdda1e2ef5e65b3ef2bb1f5c8d7f1ce4259aa56 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Wed, 13 Jan 2016 09:37:55 +0100 Subject: [PATCH 5/7] fix: typo on README --- web_easy_switch_company/README.rst | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/web_easy_switch_company/README.rst b/web_easy_switch_company/README.rst index 52d867dd..7b017a23 100644 --- a/web_easy_switch_company/README.rst +++ b/web_easy_switch_company/README.rst @@ -6,7 +6,7 @@ web_easy_switch_company ======================= -This module extend web backend and allow user to switch to another company more easyly. +This module extend web backend and allow user to switch to another company more easily. Configuration ============= @@ -14,28 +14,32 @@ Configuration To configure this module, you need to: * Enable multi company in your odoo instance -* Add your user in at least 2 company, and you will see the switch at the upper right corner +* Add your user in at least 2 companies, and you will see the switch at the upper right corner Usage ===== Functionality: -------------- - * Add a new menu in the top bar to switch to another company more easily; - * Remove the old behaviour to switch company; + +* Add a new menu in the top bar to switch to another company more easily; +* Remove the old behaviour to switch company; Documentations: --------------- - * Video : http://www.youtube.com/watch?v=Cpm6dg-IEQQ + +* Video : http://www.youtube.com/watch?v=Cpm6dg-IEQQ Technical information: ---------------------- - * Create a field function 'logo_topbar' in res_company to have a good""" + +* Create a field function 'logo_topbar' in res_company to have a good""" """resized logo; Limits: ------- - * It would be interesting to show the structure of the companies; + +* It would be interesting to show the structure of the companies; .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot From a8acc5ffb20573cd0ba0a302049426b9665ec6a7 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Wed, 13 Jan 2016 09:41:38 +0100 Subject: [PATCH 6/7] fix: remove description in __openerp__.py --- web_easy_switch_company/__openerp__.py | 30 +------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/web_easy_switch_company/__openerp__.py b/web_easy_switch_company/__openerp__.py index ebe44568..af7e2730 100644 --- a/web_easy_switch_company/__openerp__.py +++ b/web_easy_switch_company/__openerp__.py @@ -24,35 +24,7 @@ 'name': 'Multicompany - Easy Switch Company', 'version': '9.0.1.0.0', 'category': 'web', - 'description': """ -Add menu to allow user to switch to another company more easily -=============================================================== - -Functionality: --------------- - * Add a new menu in the top bar to switch to another company more easily; - * Remove the old behaviour to switch company; - -Documentations: ---------------- - * Video : http://www.youtube.com/watch?v=Cpm6dg-IEQQ - -Technical information: ----------------------- - * Create a field function 'logo_topbar' in res_company to have a good""" - """resized logo; - -Limits: -------- - * It would be interesting to show the structure of the companies; - -Copyright, Author and Licence: ------------------------------- - * Copyright: 2014, Groupement Régional Alimentaire de Proximité; - * Author: Sylvain LE GAL (https://twitter.com/legalsylvain); - * Contributor: Nicolas JEUDY (https://github.com/njeudy); - * Licence: AGPL-3 (http://www.gnu.org/licenses/)""", - 'author': "GRAP,Odoo Community Association (OCA)", + 'author': "GRAP,Sudokeys,Odoo Community Association (OCA)", 'website': 'http://www.grap.coop', 'license': 'AGPL-3', 'depends': [ From 9b1c9b1090c07de5b51c025d41dfcc891b097deb Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Wed, 13 Jan 2016 09:42:56 +0100 Subject: [PATCH 7/7] fix: rebase on 9.0 and remove README.md changes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25ff19e0..9177d8d6 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ addon | version | summary [web_dashboard_tile](web_dashboard_tile/) | 8.0.1.0.0 (unported) | Add Tiles to Dashboard [web_dialog_size](web_dialog_size/) | 8.0.0.1.0 (unported) | A module that lets the user expand a dialog box to the full screen width. [web_dom_model_classes](web_dom_model_classes/) | 8.0.1.0.0 (unported) | Allows small UI changes with simple CSS -[web_easy_switch_company](web_easy_switch_company/) | 9.0.1.0.0 | Multicompany - Easy Switch Company +[web_easy_switch_company](web_easy_switch_company/) | 8.0.1.0.0 (unported) | Multicompany - Easy Switch Company [web_environment_ribbon](web_environment_ribbon/) | 8.0.0.1.0 (unported) | Web Environment Ribbon [web_export_view](web_export_view/) | 8.0.1.2.0 (unported) | Export Current View [web_graph_improved](web_graph_improved/) | 8.0.0.1.0 (unported) | Improves graph views.