Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
7139 Lượt xem

I have multi company. I want to have different color theme (different colors for some elements) for each company in my configuration (i added fields to res_company that will contain elements colors). Users can switch their companies, and then user changed company (click top right menu -> preferences -> change company -> save) i want to change color for some elements for him (top menu background color, left menu back color, menu font color....).

what is the best way to do that ?

Ảnh đại diện
Huỷ bỏ
Tác giả

i find way to set color on load

Tác giả Câu trả lời hay nhất

i find way to set color on load by extending js

is it right way ?

var apply_theme = function(instance)
{
    if(instance)
    {
        new instance.web.Model('res.users')
            .query(['name','company_id'])
            .filter([['id', '=', instance.session.user_context.uid]])
            .first()
            .then(function (user) {
                if(user)
                {
                    new instance.web.Model('res.company')
                        .query(['name','theme_color_menu_back'])
                        .filter([['id', '=', user.company_id[0]]])
                        .first()
                        .then(function (company) {
                            if(company)
                                if(company.theme_color_menu_back)
                                    $('td.oe_topbar').css('background', company.theme_color_menu_back);
                        });
                }
            });
    };
}

openerp.my_base_ext = function(instance){

    var module = instance.web; // loading the namespace

    module.UserMenu.include({

        start: function() {
            this._super();

            apply_theme(instance);
        }

    });
};
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I created a openerp 7 module which allows you to choose templates : www.martinienolinga.com/en/plugin-des-templates-sous-openerp, You can look at source code how to do what you want

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You may have different styles by different users (including users from various companies) just by installing this module: https://apps.odoo.com/apps/modules/8.0/colors_customization/

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 4 25
12228
2
thg 12 22
13732
1
thg 6 24
2734
2
thg 12 16
5487
1
thg 3 15
5741