How to refer to user-related records in domains in view.xml

44 views
Skip to first unread message

Khurram Shahzad

unread,
Sep 9, 2017, 4:10:07 AM9/9/17
to tryton
Hi all,

I am able to get the id of the current user in the domain and use it successfully as follows:

field name="domain" eval="[('doctor_id.name.internal_user.id', '=',
Eval('context',{}).get('_user'))]" pyson="1"/>

This is good as far as we want to apply condition on Id of the user.

What if we want to get the specialty of the current user using the user Id from context and use it in a domain rule to view list of only those records which contain the same specialty?

If it is not possible, can we place some key/value data in context and refer to it in domain rules just as we referred to '_user'? This way I would be able to write the following domain rule to filter on the basis of specialty:

field name="domain" eval="[('specialty.id', '=',
Eval('context',{}).get('_specialty'))]" pyson="1"/>

Thanking you in anticipation.

Regards,
Khurram.

Cédric Krier

unread,
Sep 9, 2017, 4:25:06 AM9/9/17
to tryton
On 2017-09-08 23:02, Khurram Shahzad wrote:
> What if we want to get the specialty of the current user using the
> user Id from context and use it in a domain rule to view list of only
> those records which contain the same specialty?

The context contains only basic value like integers, strings or list but
not record instance because it must be transferred through the network.

> If it is not possible, can we place some key/value data in context and
> refer to it in domain rules just as we referred to '_user'?

You can add more values in the context of the user by extending the list
User._context_fields

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
Reply all
Reply to author
Forward
0 new messages