I have a situation where employees can see the whole list of records. But to make it a bit more friendly I have also added a ‘My Orders’ menu item. When an employee opens that menu, a (filtered) list of orders should appear where the employee is involved with. Multiple employees can be involved with an order.
To make it work I was thinking of adding a Many2Many
field to the order where employees can be added (automatically). So for each order I have a list of employees which I can use to filter out the records. My intention was to do that in the ir.action.act_window
record of the XML file, but that doesn’t work
The field:
employees = fields.Many2Many('order.order-company.employee',
'order', 'employee', 'Employees')
The XML:
<record model="ir.action.act_window" id="act_my_order_form">
<field name="name">My Orders</field>
<field name="res_model">order.order</field>
<field name="domain" eval="[
(Eval('context', {}).get('employee', None), 'in', 'employees')
]" pyson="1"/>
</record>
I also tried
<record model="ir.action.act_window" id="act_my_order_form">
<field name="name">My Orders</field>
<field name="res_model">order.order</field>
<field name="domain" eval="[
(Eval('_user.employee'), 'in', 'employees')
]" pyson="1"/>
</record>
And both the other way around (Eval
at the end).
Is this possible or do I have to add a Function
field and based on that filter the records?
In short, the employees are allowed to see all the orders, but the extra menu entry ‘My Orders’ only shows the order the employee is involved with. I am on 5.4 will 5.8 (or 6.0) any difference?