Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
7762 Vizualizări

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.


Imagine profil
Abandonează

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 Răspunsuri Vizualizări Activitate
0
feb. 22
5451
1
oct. 20
7463
0
feb. 16
4168
1
iun. 25
3015
0
apr. 19
3404