Skip to Content
Menu
This question has been flagged
5 Replies
5833 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.


Avatar
Discard

please post code , you have done so far

Author Best Answer

 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.

Avatar
Discard
Best Answer

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>
</record>

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>
</record>

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.

 

Avatar
Discard
Author

@ 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.

Author

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

Related Posts Replies Views Activity
1
Apr 18
7081
0
Jul 15
4401
2
Mar 24
574
0
Feb 24
1200
0
Jan 23
708