WAKU
WAKU

Reputation: 349

Odoo: how to use domain with group in XML?

I'm very new in odoo.

I have created a group named "group_food_manager", and a model named "food_account". Now I want to create a list/tree view that :

  1. shows the account of the current user.
  2. shows all the accounts if current user is a member of the group_food_manager group.

Here is the action of the list/tree view:

<record id="food_account_action" model="ir.actions.act_window">
        <field name="name">Accounts List</field>
        <field name="res_model">food_management.food_account</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <!--<field name="domain">[('user_id', '=', uid)]</field>-->   <---- This works
        <field name="domain">['|', ('user_id', '=', uid), ('group_food_manager', 'in', '?????']</field>  <- I don't know how to write it...
    </record>

So, is it possibile to use domian with group in XML?

Upvotes: 1

Views: 5290

Answers (2)

CZoellner
CZoellner

Reputation: 14801

You will need 2 groups: group_food_user and group_food_manager. Now you can create 2 record rules (ir.rule) the same way as for sale.order.
You will find a nice example at sale_security.

Upvotes: 1

Kenly
Kenly

Reputation: 26768

You can use groups_id field.

<field name="groups_id" eval="[(4, ref('module_name.group_food_manager'))]"/>

Upvotes: 1

Related Questions