Skip to Content
Menu
This question has been flagged

Hi all,

I want to get current user's password in POS module in Odoo 8. Because default loader which loaded database didn't load user's password. So, I used fetch for do that. Unlucky, It didn't work. Can any one help me?

Here is my code :

var password = ' ';
var loaded = fetch('res.users', ['id', 'name', 'password'],[['id', '=', instance.session.uid]]).then(function(users){
     password = users[0].password;
});
alert(password);

Whole code are in a function and when I click a button, this function will be called. Where is my wrong?


Thanks


Avatar
Discard
Best Answer

I don't know why would you need password of user but I would suggest you don't use fetch()

1. It needs server connection each time it fetches and POS is supposed to run without server connection once it is loaded
2. fetch returns async call you won't be able to return value to another function without passing a call back.

I suggest you to add password field in model 'res.users' for it be available in POS session, you can do it with inheritance like



module.PosModel.prototype.models.filter(function (m)
        { return m.model === 'res.users'; }).map(function (m) {
              return m.fields.push('password'),
         m;
});



this way password will be available in your POS session and you will not need to fetch it every time from server which would need connection to server.

then you can access it something like

this.pos.user.password;



cheers ;-)

Avatar
Discard
Author Best Answer

Hi, I try to access as yours, but the password is empty. I also try to change user's password but I can't get it.

I can access login, signature's value or something like that in model "res.user". But I can't get value of password or new_password, I got blank in this case. The value same ""

Avatar
Discard

It must not be blank, also "this.pos.user.password" might change depending on the function scope where do you want to access value, if it is saying undefined or "" ?? if it is undefined it means your field is not available to access but if it says "" then congratulations you have added 'password' field in POS, in that case try adding other field eg: 'login' and access its value, if you don't get put a breakpoint on the line where do you want to access its value and debug it. good luck :)

Hi Yogesh,

I can access login, signature's value or something like that in model "res.user". But I can't get value of password or new_password, I got blank in this case.

2015-05-15 10:38 GMT+07:00 Yogesh <yogeshkushwaha4-gmail-com@mail.odoo.com>:

It must not be blank, also "this.pos.user.password" might change depending on the function scope where do you want to access value, if it is saying undefined or "" ?? if it is undefined it means your field is not available to access but if it says "" then congratulations you have added 'password' field in POS, in that case try adding other field eg: 'login' and access its value, if you don't get put a breakpoint on the line where do you want to access its value and debug it. good luck :)

--
Yogesh
Sent by Odoo S.A. using Odoo about Forum Post False



--
Trần Như Văn
MSSV: 51104177
K11 Bách Khoa Tp.HCM
Khoa: Khoa học và Kĩ thuật máy tính
Related Posts Replies Views Activity
0
May 15
3203
1
Aug 24
547
3
May 24
7294
1
Sep 23
1350
0
Aug 23
559