Search code examples
node.jsexpressodoo

How to get current logged in user id in odoo and node js


I want to display the current logged in user-id. I'm using odoo-xmlrpc node module to connect my express and odoo application.

odoo.execute_kw("res.users", "search_read", params, function( err,result) {
          if (err) {
            return console.log(err);
          }
          res.json(result);
        });

here I can return all users. But I want to return the current user. I have found this article which is done with python


Solution

  • The connect method returns the current logged user-id uid after a successful login.
    You can get it there:

    odoo.connect(function (err, uid) {
        if (err) { return console.log(err); }
        console.log('Connected to Odoo server.');
        console.log('uid', uid)  
    });