Tags

,


1).Create a new file module/security/security.xml
2) Create module/security/ir.model.access.csv
3). Finally update openacademy/__openerp__.py

 'data': [
        'security/security.xml',
        'security/ir.model.access.csv',
]

 

4). Edit security.xml

<openerp>
 <data>
 <record id="vetclinic_group_user" model="res.groups">
 <field name="name">Vetclinic / User</field>
 </record>
 
 <record id="rule_vetclinic_group_user" model="ir.rule">
 <field name="name">Vetclinic / User</field>
 <field name="model_id" ref="model_vetclinic_animal"/>
 <field name="groups" eval="[(4, ref('vetclinic_group_user'))]"/>
 <field name="perm_read" eval="1"/>
 <field name="perm_write" eval="0"/>
 <field name="perm_create" eval="0"/>
 <field name="perm_unlink" eval="0" />
 <field name="domain_force">[('user','=',user.id)]</field>
 </record>
 </data>
</openerp>

5). Edit ir.model.access.csv

id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
clinic_user Clinic User model_vetclinic_animal vetclinic_group_user 1 0 0 0

6). .py class

class vetclinic_animal(osv.osv):
 _name = "vetclinic.animal"
 _columns = {
 'name' : fields.char('Name', size=64),
 'birthdate' : fields.date('Birth Date'),
 'classification_id':fields.many2one('vetclinic.classification','Classification'),
 'breed_id':fields.many2one('vetclinic.breed','Breed'),
 'labels_ids':fields.many2many('vetclinic.labels','rel_animal_labels','animal_id','labels_id',"Label"),
 'history':fields.text("History"),
 'address':fields.text("Address"),
 'res_partner_id':fields.many2one('res.partner','Owner'),
 'user':fields.many2one('res.users','User')
 }
Advertisements