Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
7769 Visualizzazioni

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.    


Avatar
Abbandona
Risposta migliore

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).

Avatar
Abbandona
Autore

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

Post correlati Risposte Visualizzazioni Attività
1
dic 19
4965
2
ago 23
2809
3
dic 20
9915
0
apr 15
4861
1
mar 25
2566