Unable to get current user id

68 views
Skip to first unread message

Khurram Shahzad

unread,
Sep 4, 2017, 3:22:16 AM9/4/17
to try...@googlegroups.com
Hi all,

I want to display the appointments of currently logged in user. For this I wrote following record in the view.xml:

<field name="domain" eval="[('healthprof.name.internal_user.id', '=', Eval('user.id'))]" pyson="1"/>

When I click on the tab which displays these records, following error is displayed:
DataError: invalid input syntax for integer: ""
LINE 1: ..."."internal_user") WHERE (true AND (((("d"."id" = '') AND ("...
                                                             ^

I checked PostgreSQL log, and got query from there. It looks as if the id of the current user is not passed in the query.

Any ideas on how can I correctly get the id of the current user logged in.
--
 
Regards,
Khurram.

Cédric Krier

unread,
Sep 5, 2017, 5:35:07 AM9/5/17
to try...@googlegroups.com
On 2017-08-23 16:02, Khurram Shahzad wrote:
> Hi all,
>
> I want to display the appointments of currently logged in user. For this I
> wrote following record in the view.xml:
>
> <field name="domain" eval="[('healthprof.name.internal_user.id', '=', Eval('
> user.id'))]" pyson="1"/>

You can not use dot notation inside Eval.
I guess you want to have the user id from the context so you must use:

Eval('context', {}).get('user')

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Khurram Shahzad

unread,
Sep 5, 2017, 1:35:07 PM9/5/17
to try...@googlegroups.com
On Tue, Sep 5, 2017 at 2:35 PM, Cédric Krier <cedric...@b2ck.com> wrote:
On 2017-08-23 16:02, Khurram Shahzad wrote:
> Hi all,
>
> I want to display the appointments of currently logged in user. For this I
> wrote following record in the view.xml:
>
> <field name="domain" eval="[('healthprof.name.internal_user.id', '=', Eval('
> user.id'))]" pyson="1"/>

You can not use dot notation inside Eval.
I guess you want to have the user id from the context so you must use:

    Eval('context', {}).get('user')

I tried it as follows:
 <field name="domain" eval="[('doctor_id.name.internal_user.id', '=', Eval('context',{}).get('user'))]" pyson="1"/>

But, it failed with following exception:
Invalid input syntax for integer: "" at character 1406.

When I checked query in the postgreSQL log, I found  "d"."id" = '' where "d" is alias for res_user table.

Thank you very much for the response.

Regards,
Khurram.

Cédric Krier

unread,
Sep 5, 2017, 2:05:08 PM9/5/17
to try...@googlegroups.com
Indeed the key is '_user' not 'user'.

Khurram Shahzad

unread,
Sep 6, 2017, 2:30:07 AM9/6/17
to try...@googlegroups.com
On Tue, Sep 5, 2017 at 11:03 PM, Cédric Krier <cedric...@b2ck.com> wrote:
On 2017-09-05 22:11, Khurram Shahzad wrote:
> On Tue, Sep 5, 2017 at 2:35 PM, Cédric Krier <cedric...@b2ck.com> wrote:
>
> > On 2017-08-23 16:02, Khurram Shahzad wrote:
> > > Hi all,
> > >
> > > I want to display the appointments of currently logged in user. For this
> > I
> > > wrote following record in the view.xml:
> > >
> > > <field name="domain" eval="[('healthprof.name.internal_user.id', '=',
> > Eval('
> > > user.id'))]" pyson="1"/>
> >
> > You can not use dot notation inside Eval.
> > I guess you want to have the user id from the context so you must use:
> >
> >     Eval('context', {}).get('user')
> >
>
> I tried it as follows:
>  <field name="domain" eval="[('doctor_id.name.internal_user.id', '=',
> Eval('context',{}).get('user'))]" pyson="1"/>
>
> But, it failed with following exception:
> Invalid input syntax for integer: "" at character 1406.
>
> When I checked query in the postgreSQL log, I found  "d"."id" = '' where
> "d" is alias for res_user table.

Indeed the key is '_user' not 'user'.


Great! It's working now!
--
 
Regards,
Khurram.
Reply all
Reply to author
Forward
0 new messages