Setting up rules Access Right in xml


Access Rules This is how you can create access rules for particular object and groups by creating xml file.

For example:

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

 <record id="property_rule_ep_hr_recruitment_multicompany" model="ir.rule">
 <field name="name">Recruitment Request Multi Company</field>
 <field name="model_id" ref="model_ep_hr_recruitment"/>
 <field name="domain_force">['|',('company_id', 'in', [g.id for g in user.company_ids]),('company_id','=',False)]</field>
 </record>
 
 <record id="rule_ep_hr_recruitment_request_officer" model="ir.rule">
 <field name="name">Recruitment Request</field>
 <field name="model_id" ref="model_ep_hr_recruitment"/>
 <field name="domain_force">['|',('employee_id.parent_id.user_id','=',user.id),('employee_id.user_id','=',user.id)]</field>
 <field name="perm_read" eval="True"/>
 <field name="perm_create" eval="True"/>
 <field name="perm_write" eval="True"/>
 <field name="perm_unlink" eval="False"/>
 <field name="groups" eval="[(4,ref('base.group_hr_user'))]"/>
 </record>
 
 <record id="rule_ep_hr_recruitment_request_manager" model="ir.rule">
 <field name="name">Recruitment Request</field>
 <field name="model_id" ref="model_ep_hr_recruitment"/>
 <field name="domain_force">['|',('company_id', 'in', [g.id for g in user.company_ids]),('company_id','=',False)]</field>
 <field name="groups" eval="[(4,ref('base.group_hr_manager'))]"/>
 </record>
 
 
 </data>
 </openerp>

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s