forked from Techsystech/web
commit
529e7cb8b0
|
@ -1,20 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
|
@ -1,51 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{
|
||||
"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': [],
|
||||
},
|
||||
}
|
|
@ -19,6 +19,5 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import model
|
||||
from . import controllers
|
|
@ -66,6 +66,6 @@ Copyright, Author and Licence:
|
|||
'qweb': [
|
||||
'static/src/xml/switch_company.xml',
|
||||
],
|
||||
'installable': False,
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
#############################################################################
|
||||
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
|
|
@ -1,5 +1,5 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
# #############################################################################
|
||||
#
|
||||
# Web Easy Switch Company module for OpenERP
|
||||
# Copyright (C) 2014 GRAP (http://www.grap.coop)
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 112 B After Width: | Height: | Size: 112 B |
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 445 B |
|
@ -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'));
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -21,24 +21,29 @@
|
|||
<template>
|
||||
|
||||
<t t-name="web_easy_switch_company.SwitchCompanyWidget">
|
||||
<span class="oe_user_menu oe_topbar_item oe_dropdown_toggle oe_dropdown_arrow">
|
||||
<span>
|
||||
<t t-esc="widget.current_company_name"/>
|
||||
</span>
|
||||
<ul class="oe_dropdown_menu">
|
||||
<t t-foreach="widget.companies" t-as="company">
|
||||
<li>
|
||||
<a class="easy_switch_company_company_item"
|
||||
href="#"
|
||||
t-att-data-company-id="company.id">
|
||||
<img class="oe_topbar_avatar" t-att-src="company.logo_topbar"/>
|
||||
<img class="oe_topbar_avatar" t-att-src="company.logo_state"/>
|
||||
<t t-esc="company.name"/>
|
||||
</a>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</span>
|
||||
<ul class="nav navbar-nav navbar-right oe_user_menu_placeholder" style="margin-right:10px">
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
<span class="oe_topbar_name">
|
||||
<t t-esc="widget.current_company_name"/>
|
||||
</span>
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<t t-foreach="widget.companies" t-as="company">
|
||||
<li>
|
||||
<a class="easy_switch_company_company_item"
|
||||
href="#"
|
||||
t-att-data-company-id="company.id">
|
||||
<img class="oe_topbar_avatar" t-att-src="company.logo_topbar"/>
|
||||
<img class="oe_topbar_avatar" t-att-src="company.logo_state"/>
|
||||
<t t-esc="company.name"/>
|
||||
</a>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
|
||||
</template>
|
|
@ -13,5 +13,12 @@
|
|||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<template id="assets_backend" name="web_tests assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/web_easy_switch_company/static/src/js/switch_company.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue