Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
7574 Zobrazení

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.


Avatar
Zrušit

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

Autor

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?

Autor

odoo 10 EE

Autor

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);

Autor

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.

Autor

ok, np. I will let you know.

Autor

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

Related Posts Odpovědi Zobrazení Aktivita
0
úno 22
5313
1
říj 20
7250
0
úno 16
4047
1
čvn 25
2786
0
dub 19
3164