Odoo ir.rule domain_force for group role取决于州

时间:2017-05-24 12:20:52

标签: openerp odoo-9 access-rights

我有3个组角色:用户,经理和逻辑。并且需要状态'已批准'的用户和经理以及'to_approve_second'没有正确的写作权。

所有用户都写得正确,并且有ir.rules:

    <field name="name">Follow Purchase Request</field>

    <field name="model_id" ref="model_purchase_request"/>

    <field name="groups" eval="[(6,0, [ref('group_purchase_request_user')])]"/>

    <field name="perm_read" eval="True"/>

    <field name="perm_write" eval="False"/>

    <field name="perm_create" eval="False"/>

    <field name="perm_unlink" eval="False"/>

    <field name="domain_force">['|',('requested_by','=',user.id),

                                    ('message_partner_ids', 'in', [user.partner_id.id])]</field>

</record>



<record id="purchase_request_rule" model="ir.rule">

    <field name="name">Purchase Request User</field>

    <field name="model_id" ref="model_purchase_request"/>

    <field name="groups" eval="[(6,0, [ref('group_purchase_request_user')])]"/>

    <field name="perm_read" eval="True"/>

    <field name="perm_write" eval="True"/>

    <field name="perm_create" eval="True"/>

    <field name="perm_unlink" eval="True"/>

    <field name="domain_force">[('requested_by','=',user.id)]</field>

</record>



<record id="purchase_request_manager_rule" model="ir.rule">

    <field name="name">Purchase Request Manager</field>

    <field name="model_id" ref="model_purchase_request"/>

    <field name="groups" eval="[(6,0, [ref('group_purchase_request_manager')])]"/>

    <field name="perm_read" eval="True"/>

    <field name="perm_write" eval="True"/>

    <field name="perm_create" eval="True"/>

    <field name="perm_unlink" eval="True"/>

</record>

我试图添加:

    <field name="name">Purchase Request User Rule</field>

    <field name="model_id" ref="model_purchase_request"/>

    <field name="groups" eval="[(6,0, [ref('group_purchase_request_user')])]"/>

    <field name="perm_read" eval="True"/>

    <field name="perm_write" eval="False"/>

    <field name="perm_create" eval="False"/>

    <field name="perm_unlink" eval="False"/>

    <field name="domain_force">[('state','in',('approved', 'to_approve_second'))]</field>

</record>

    <field name="name">Purchase Request Manager Rule</field>

    <field name="model_id" ref="model_purchase_request"/>

    <field name="groups" eval="[(6,0, [ref('group_purchase_request_manager')])]"/>

    <field name="perm_read" eval="True"/>

    <field name="perm_write" eval="False"/>

    <field name="perm_create" eval="False"/>

    <field name="perm_unlink" eval="False"/>

    <field name="domain_force">[('state','in',('approved', 'to_approve_second'))]</field>

</record>

但没有任何反应。用户和管理员可以在“已批准”和“to_approve_second”状态下编辑文档。 什么可能是错的?

1 个答案:

答案 0 :(得分:0)

我找到了一个有效的解决方案!

<record id="purchase_request_followers_rule" model="ir.rule">
    <field name="name">Follow Purchase Request</field>
    <field name="model_id" ref="model_purchase_request"/>
    <field name="groups" eval="[(6,0, [ref('group_purchase_request_user')])]"/>
    <field name="perm_read" eval="True"/>
    <field name="perm_write" eval="False"/>
    <field name="perm_create" eval="False"/>
    <field name="perm_unlink" eval="False"/>
    <field name="domain_force">['|',('requested_by','=',user.id),
                                    ('message_partner_ids', 'in', [user.partner_id.id])]</field>
</record>

<record id="purchase_request_rule" model="ir.rule">
    <field name="name">Purchase Request User</field>
    <field name="model_id" ref="model_purchase_request"/>
    <field name="groups" eval="[(6,0, [ref('group_purchase_request_user')])]"/>
    <field name="perm_read" eval="True"/>
    <field name="perm_write" eval="False"/>
    <field name="perm_create" eval="False"/>
    <field name="perm_unlink" eval="False"/>
    <field name="domain_force">[('requested_by','=',user.id)]</field>
</record>

<record id="no_edit_rule" model="ir.rule">
    <field name="name">No Edit Rule</field>
    <field name="model_id" ref="model_purchase_request"/>
    <field name="groups" eval="[(6,0, [ref('group_purchase_request_user')])]"/>
    <field name="perm_read" eval="False"/>
    <field name="perm_write" eval="True"/>
    <field name="perm_create" eval="False"/>
    <field name="perm_unlink" eval="False"/>
    <field name="domain_force">[('requested_by','=',user.id),('state','not in',('approved', 'to_approve_second'))]

    

<record id="purchase_request_manager_rule" model="ir.rule">
    <field name="name">Purchase Request Manager</field>
    <field name="model_id" ref="model_purchase_request"/>
    <field name="groups" eval="[(6,0, [ref('group_purchase_request_manager')])]"/>
    <field name="perm_read" eval="False"/>
    <field name="perm_write" eval="True"/>
    <field name="perm_create" eval="False"/>
    <field name="perm_unlink" eval="False"/>
    <field name="domain_force">[('assigned_to','=',user.id),('state','in',('to_approve_first', 'create_order'))]

    

<record id="manager_manager_rule" model="ir.rule">
    <field name="name">Manager manager</field>
    <field name="model_id" ref="model_purchase_request"/>
    <field name="groups" eval="[(6,0, [ref('group_purchase_request_manager')])]"/>
    <field name="perm_read" eval="True"/>
    <field name="perm_write" eval="False"/>
    <field name="perm_create" eval="False"/>
    <field name="perm_unlink" eval="False"/>
    <field name="domain_force">[('assigned_to','=',user.id)]</field>
</record>