Odoo Help


In Javascript, how to set a boolean variable for Users.call?

v8 js
Alejandro Santana
on 4/18/15, 8:05 AM 1,030 views

In Odoo v8 and within a javascript file, I want to set a boolean variable to show if a user has (belongs to) an specific group or not.

I know the function, as I can use it with *.done().fail()", but I am not able to use it correctly to a variable to use later.

If I do this:

var my_var = false;
my_var = Users.call('has_group', ['import_csv_restrict.group_import_csv_allow']);

I do get a result of my_var =  [object Object], but I need it to be a boolean. How to do it?

I have also tried to do:

var my_var = false;
sers.call('has_group', ['import_csv_restrict.group_import_csv_allow'])
.done(function() {my_var = true;};)
.fail(function() {my_var = false;};);

But my_var is actually not affected.

Alejandro Santana
On 4/21/15, 10:58 PM

I was missing a callback argument there. This works:

var my_var = false;
var Users = new openerp.web.Model('res.users');
Users.call('has_group', ['import_csv_restrict.group_import_csv_allow'])
.then(function(result) {my_var = result;};);

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/18/15, 8:05 AM
Seen: 1030 times
Last updated: 4/21/15, 10:58 PM