跳至内容
菜单
此问题已终结
1 回复
7755 查看

I'm trying to add a rule to manage the following behaviour:

Users which belong to the base.group_sale_salesman group must only see the partners which are from the same state of them.

I added the next rule: 

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

<openerp>

   <data noupdate="0">

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

         <field name="name">res_partner: read only partners from your state</field>

         <field name="model_id" ref="base.model_res_partner"/>

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

         <field name="groups" eval="[(4, ref('base.group_sale_salesman'))]"/> 

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

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

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

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

      </record>

   </data>

</openerp> 

But it's getting the next error:

ParseError: "new row for relation "ir_rule" violates check constraint "ir_rule_no_access_rights"

I was googling that error but I din't find anything which was able to help me.

This is the first ir.rule I do, may be there are several mistakes I can't notice.

Can anyone help me, please? Thank you in advance.    


形象
丢弃
最佳答案

Hi,

you need to make some changes as like below.


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

<field name="name">res_partner: read only partners from your state</field>

<field name="model_id" ref="base.model_res_partner"/>

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

<field name="groups" eval="[(4, ref('base.group_sale_salesman'))]"/> 

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

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

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

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

</record>

You have to give True value in any one of the rights. (read, write, unlink or create).

形象
丢弃
编写者

Excellent @Emipro Technologies Pvt. Ltd.! Thank you very much!

相关帖文 回复 查看 活动
1
12月 19
4943
2
8月 23
2795
3
12月 20
9896
0
4月 15
4854
1
3月 25
2552