<?xml version="1.0" encoding="utf-8"?>
<odoo>

<data noupdate="1">

    <!-- Multi Company -->
    <record id="rma_rma_company_rule" model="ir.rule">
        <field name="name">RMA: RMA</field>
        <field name="model_id" ref="model_rma_rma"/>
        <field name="global" eval="True"/>
        <field name="domain_force">['|',
                                        ('company_id', '=', False),
                                        ('company_id', 'in', company_ids),
                                    ]</field>
    </record>

    <record id="rma_template_company_rule" model="ir.rule">
        <field name="name">RMA: RMA Template</field>
        <field name="model_id" ref="model_rma_template"/>
        <field name="global" eval="True"/>
        <field name="domain_force">['|',
                                        ('company_id', '=', False),
                                        ('company_id', 'in', company_ids),
                                    ]</field>
    </record>

    <!-- Portal Access Rules -->
    <record id="rma_rule_portal" model="ir.rule">
        <field name="name">Portal Personal RMAs</field>
        <field name="model_id" ref="rma.model_rma_rma"/>
        <field name="domain_force">[('partner_id','child_of',[user.commercial_partner_id.id])]</field>
        <field name="groups" eval="[(4, ref('base.group_portal'))]"/>
        <field name="perm_unlink" eval="False"/>
        <field name="perm_write" eval="False"/>
        <field name="perm_read" eval="True"/>
        <field name="perm_create" eval="False"/>
    </record>

    <record id="rma_line_rule_portal" model="ir.rule">
        <field name="name">Portal RMA Line</field>
        <field name="model_id" ref="rma.model_rma_line"/>
        <field name="domain_force">[('rma_id.partner_id','child_of',[user.commercial_partner_id.id])]</field>
        <field name="groups" eval="[(4, ref('base.group_portal'))]"/>
        <field name="perm_unlink" eval="False"/>
        <field name="perm_write" eval="False"/>
        <field name="perm_read" eval="True"/>
        <field name="perm_create" eval="False"/>
    </record>

</data>
</odoo>
