This question has been flagged
3 Replies
14419 Views

Hi All, 
 If anyone help about how to get users info for a particular session in openerp, like user id for that session and their password. 

 

Thanks

Avatar
Discard
Best Answer

Hi,

I don't know where you can find the session (I think Odoo web client send password and login for each request to the server)

So you can have some information into the _uid_cache inside a res_users inherited object like:

 

class my_model(osv.Model):

      _inherit = 'res.users'

 

you can check into the res_users.py file:

https://github.com/odoo/odoo/blob/7.0/openerp/addons/base/res/res_users.py#L126

there are a _uid_cache dictionnary which contains the password for the current user and probably more data(I don't check).

And this is the login function call when you click Login on the login odoo page:

https://github.com/odoo/odoo/blob/7.0/openerp/addons/base/res/res_users.py#L406

Probably try to override it if you want to store the data.

 

Hope this help a little.

 

Avatar
Discard
Best Answer

Hello Abhishek,

You can directly fetch the user info from pgadmin.
In your .py file for any custom function you specify uid such as
def custom_func(self,cr,uid,ids,context):
    user_obj=self.pool.get('res.users').read(cr,uid,uid,['name','login','password'])
    print user_obj #gives u all info about the current login user.
    
I am not sure about why your query is focused more on users under current sessions because whatever the sessions will be ,the user info will be authenticated from openerp models/objects.Hence you can directly fetch user info from pgadmin.

Though i dont have knowlegde of backbone js but following code might help you to play with sessions:

1. Go to /addons/web/static/src/js
2. open chrome.js
3. find this function:
    do_login: function (db, login, password) {
        var self = this;
        self.hide_error();
        self.$(".oe_login_pane").fadeOut("slow");
        return this.session.session_authenticate(db, login, password).then(function() {
            self.remember_last_used_database(db);
            if (self.has_local_storage && self.remember_credentials) {
                localStorage.setItem(db + '|last_login', login);
            }
            self.trigger('login_successful');
        }, function () {
            self.$(".oe_login_pane").fadeIn("fast", function() {
                self.show_error(_t("Invalid username or password"));
            });
        });
    },

Avatar
Discard
Author Best Answer

Dear Friends Thanks for your answers but this is not the things what I am looking for...

Basically what I am looking is based on web moudule specially to get HTTP/JSON request in OpenERP.
I am using currently openerp.addons.web.session import OpenERPSession mainly _cp_path and (openerpweb.Controller) so  not able to call directly any osv.model from here.

My need is similar like to send some and http request to a third party server, and then that server will do the process on the given data by that http request and than that third party server will return sucess/reponse message to openerp through a return url on openerp, which is working currently very fine able to get the reponse from thrid party server but for storing the same data I am trying to store in related table of openerp with web services (xmlrpclib), for which I need the user info of a session in OpenERP. currently just getting a session id , database name. host name & port etc... but not user info.

If possible kindly let me know if someone ca suggest better.

Avatar
Discard