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

Code 1:

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


Code 2:

if (Users.call('has_groups', ['group_account_manager']).done(function(belongs_to_all_groups) {
if(belongs_to_all_groups){

Code 3:

var user = require('res.users');
if (user.call('has_groups', ['group_account_manager']).done(function(belongs_to_all_groups) {
if(belongs_to_all_groups){..}

Attempts that didn't work in v12

Imagine profil
Abandonează
Cel mai bun răspuns

Your code is not working because you are not passing logged in user's ID.

Try the following code:

var Session = require('web.session');
var Model = require('web.Model');

var Users = new Model('res.users');

Users.call('has_group', [Session.uid, 'account.group_account_manager']).then(function(result) {
if (result) {
//your code goes here....
}
})


Imagine profil
Abandonează
Autor

Thanks, it worked !!

Cel mai bun răspuns

Hello, MatheusF


You can get the user group from the session.

Code :


var session = require('web.session');


session.user_has_group('analytic.group_analytic_tags').then(function(has_group) {

    if(has_group) {

        // code

    } else {

        // code

    }

});


For More Information Contact Us :- https://kanakinfosystems.com/odoo-development-services


Imagine profil
Abandonează
Autor

Thanks, it worked !!

Related Posts Răspunsuri Vizualizări Activitate
2
sept. 20
6245
7
apr. 23
28391
0
apr. 18
3474
1
mar. 25
955
1
ian. 24
1868