Browse Source

Merge pull request #260 from Sudokeys/web_easy_switch_company_migrate_90

[MIG] web_easy_switch_company: migrate to 9.0
pull/377/head
Pedro M. Baeza 9 years ago
parent
commit
72585fb75a
  1. 92
      web_easy_switch_company/README.rst
  2. 33
      web_easy_switch_company/__openerp__.py
  3. 35
      web_easy_switch_company/static/src/js/switch_company.js
  4. 1
      web_easy_switch_company/static/src/xml/switch_company.xml

92
web_easy_switch_company/README.rst

@ -0,0 +1,92 @@
.. 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 easily.
Configuration
=============
To configure this module, you need to:
* Enable multi company in your odoo instance
* 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;
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
<https://github.com/OCA/web/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
<https://github.com/OCA/
web/issues/new?body=module:%20
web_easy_switch_company%0Aversion:%20
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
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.

33
web_easy_switch_company/__openerp__.py

@ -22,36 +22,9 @@
{
'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
===============================================================
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);
* 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': [
@ -63,6 +36,6 @@ Copyright, Author and Licence:
'qweb': [
'static/src/xml/switch_company.xml',
],
'installable': False,
'installable': True,
'auto_install': False,
}

35
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,13 +18,20 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
openerp.web_easy_switch_company = function (instance) {
odoo.define('web.web_easy_switch_company',function (require) {
"use strict";
var Widget = require('web.Widget');
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
from a company to another more easily.
***************************************************************************/
instance.web.SwitchCompanyWidget = instance.web.Widget.extend({
var SwitchCompanyWidget = Widget.extend({
template:'web_easy_switch_company.SwitchCompanyWidget',
@ -84,7 +92,7 @@ openerp.web_easy_switch_company = function (instance) {
* 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,6 +102,7 @@ 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];
@ -104,7 +113,7 @@ 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.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;
@ -138,18 +147,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);
});

1
web_easy_switch_company/static/src/xml/switch_company.xml

@ -47,4 +47,3 @@
</t>
</template>
Loading…
Cancel
Save