<odoo>
    <data>
        <record id="group_purchase_own_orders" model="res.groups">
            <field name="name">User (own orders)</field>
            <field name="category_id" ref="base.module_category_inventory_purchase" />
            <field
                name="implied_ids"
                eval="[(4, ref('purchase.group_purchase_user'))]"
            />
        </record>
        <record id="group_purchase_group_orders" model="res.groups">
            <field name="name">User (team orders)</field>
            <field name="category_id" ref="base.module_category_inventory_purchase" />
            <field
                name="implied_ids"
                eval="[(4, ref('purchase_security.group_purchase_own_orders'))]"
            />
        </record>
        <record id="purchase.group_purchase_manager" model="res.groups">
            <field
                name="implied_ids"
                eval="[(3, ref('purchase.group_purchase_user')),
                (4, ref('group_purchase_own_orders')),(4, ref('group_purchase_group_orders'))]"
            />
        </record>
    </data>
    <data noupdate="1">
        <record model="ir.rule" id="purchase_order_group_purchase_manager_rule">
            <field name="name">View purchase orders (manager)</field>
            <field name="model_id" ref="purchase.model_purchase_order" />
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('purchase.group_purchase_manager'))]" />
        </record>
        <record model="ir.rule" id="purchase_order_group_purchase_order_own_orders">
            <field name="name">View purchase orders (own responsible)</field>
            <field name="model_id" ref="purchase.model_purchase_order" />
            <field
                name="domain_force"
            >['|',('user_id','=',user.id),'&amp;',('user_id','=',False),('team_id','=',False)]</field>
            <field name="groups" eval="[(4,ref('group_purchase_own_orders'))]" />
        </record>
        <record model="ir.rule" id="purchase_order_group_purchase_order_group_orders">
            <field name="name">View purchase orders (purchase team member)</field>
            <field name="model_id" ref="purchase.model_purchase_order" />
            <field name="domain_force">[('team_id.user_ids', '=', user.id)]</field>
            <field name="groups" eval="[(4,ref('group_purchase_group_orders'))]" />
        </record>
        <record model="ir.rule" id="purchase_order_line_group_purchase_manager_rule">
            <field name="name">View purchase order lines (manager)</field>
            <field name="model_id" ref="purchase.model_purchase_order_line" />
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('purchase.group_purchase_manager'))]" />
        </record>
        <record
            model="ir.rule"
            id="purchase_order_line_group_purchase_order_own_orders"
        >
            <field name="name">View purchase order lines (own responsible)</field>
            <field name="model_id" ref="purchase.model_purchase_order_line" />
            <field
                name="domain_force"
            >['|',('order_id.user_id','=',user.id),'&amp;',('order_id.user_id','=',False),('order_id.team_id','=',False)]</field>
            <field name="groups" eval="[(4,ref('group_purchase_own_orders'))]" />
        </record>
        <record model="ir.rule" id="purchase_order_user_group_purchases_rule">
            <field name="name">View purchase order lines (purchase responsible)</field>
            <field name="model_id" ref="purchase.model_purchase_order_line" />
            <field
                name="domain_force"
            >[('order_id.team_id.user_ids', '=', user.id)]</field>
            <field name="groups" eval="[(4, ref('group_purchase_group_orders'))]" />
        </record>
    </data>
</odoo>
