Odoo Help

0

How to add a rule?

By
Juan Formoso
on 4/23/15, 7:31 AM 1,313 views

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.    


1

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!

Juan Formoso
on 4/23/15, 9:47 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 4/23/15, 7:31 AM
Seen: 1313 times
Last updated: 4/23/15, 9:50 AM