Odoo Help


Odoo9: Dynamic Domain in Window Action

on 5/18/16, 4:03 AM 955 views

I wanted to set the domain criteria dynamically on the window action (ir.actions.act_window) for specific user.

Note: I don't want to use any Security Rules on the object, though it gives the result what am looking for,  but it is a hindrance in couple of places wherein it fails to perform my internal functionality.

In other words, User should not have visual access to couple of records, but should be available to perform the internal actions.

Best Example, I can take is Partners:

Under "Contacts" menu, Both Supplier & Customer contacts are been shown.

Now I want to filter the contacts which are shown in that Contact menu according to the User.

Say User A (belonging to SalesGroup) should access to view Customer Contacts in that menu, User B (belonging to PurchaseGroup) should be able to see only Suppliers in that menu.

But this should not affect Sale/Purchase Contacts w.r.t Sale/Purchase orders.

Any help appreciated.

please post code , you have done so far

webkul, Prakash Sharma
on 5/18/16, 5:58 AM
On 11/10/16, 6:03 AM

 Made the contacts menu itself invisible to serve the purpose, thanks anyways to all who tried to help me,

However I already migrated to Odoo 10, where in by Contacts menu is not present any more, hence Search_default does the much need activity.


Hi Deep,

You can use "uid" variable in right hand side of domain to manage dynamic domain inside any window action. Please have a look inside below example.

<record model="ir.actions.act_window" id="action_note_stage">
<field name="name">Stages</field>
<field name="res_model">note.stage</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('user_id','=',uid)]</field>

Another one.

<record id="expense_all" model="ir.actions.act_window">
<field name="name">My Expenses</field>
<field name="res_model">hr.expense</field>
<field name="view_mode">tree,kanban,form,graph,pivot</field>
<field name="search_view_id" ref="view_hr_expense_filter"/>
<field name="domain">[('employee_id.user_id', '=', uid)]</field>

I hope you will get dynamic domain as you want from above examples.

Note : You can use some predefined variables in domain like : uid, active_id, active_ids, time etc.


@ Empiro, Thanks for the reply, but no, as I told you earlier, it is based on the UserGroup and not uid. For Instance: users belonging to Sales Group should be able to access only Customer(i.e Contacts set as customer) similarly Purchase Group should be able to access only Supplier Contacts.

on 5/23/16, 3:21 AM

Sorry: I had missed to mention, it is w.r.t to UserGroups not on User.

on 5/23/16, 3:23 AM

About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/18/16, 4:03 AM
Seen: 955 times
Last updated: 11/10/16, 6:15 AM