Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
7582 Представления

I have written following code in js to change the odoo menu-color:

odoo.define('cof_backend_theme.style', function (require) {'use strict';
     
var ajax = require('web.ajax');
ajax.jsonRpc("/action_get_menu_color", 'call').then(function(value){
$(document).ready(function(){
$(".o_main_navbar").css("background-color", value); //value #000 comes correctly
});
}); });


The js value #000 comes from the backend. But the color in odoo isn't changing.

If I debug the controller code in pycharm I can see the menu color change (works) but when I run the code without debugging the color doesn't change.

What to do? Please suggest.


Аватар
Отменить

I had faced the same issue

Same selector works in css, but not in js

I think the line

$(document).ready(function(){ }); is not required

Автор

yes, that doesn't require. I was seeing if the js loads while loading the page.

Is there any fix you know about?

Which is your version?

Автор

odoo 10 EE

Автор

I just tested on community edition it worked. But not works on enterprise edition. That is even more weirder :(

See this reference in odoo 8

https://www.odoo.com/apps/themes/8.0/editable_theme/

You download it

go to the file

/editable_theme/static/src/js/js_role.js

You can see many examples

Such as

$(".navbar-collapse.collapse").css("background-color", topBar_background_COLOR_CODE);

Автор

thank you very much. I will study this module tonight and let you know.

But my concern is why a code is working on debug mode or CE but not on EE. :\

I have no idea about EE.

Автор

ok, np. I will let you know.

Автор

@Shameem, I used the method the module used but no result. If I write static css, it works. But not from js.

Related Posts Ответы Просмотры Активность
0
февр. 22
5322
1
окт. 20
7259
0
февр. 16
4058
1
июн. 25
2803
0
апр. 19
3170