Odoo Help

Welcome!

This community 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.

0

Users Info of a session openERPSession for httprequest (OpenERP version - 7 ) through session id

By
Abhishek
on 7/28/14, 5:30 AM 3,897 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

0
Clement Zotti
On 7/28/14, 4:23 PM

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.

 

0
shashank verma
On 7/28/14, 4:31 PM

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"));
            });
        });
    },

0
Abhishek
On 7/29/14, 2:54 PM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/28/14, 5:30 AM
Seen: 3897 times
Last updated: 3/16/15, 8:10 AM