Thursday, 6 June 2013

Field level Security in OpenERP

Field level Security in OpenERP

In openerp erp its some times its needed to secure system.

So, there are lots of way to secure System. You can create access rights, Groups or etc.

But i think some times needed to field level security also. So, we can simply groups= "xyz group" so it will simply manage and that particular user can access. You can also restrict from xml also.

But if you try same thing in 7 also than you find if in fields you put "group1" and now, if you login with other group user which have all access rights of current object and you have put another group on fields than it will give you access rights warning and not able to access whole object.

So, in that case you can achieve from following code.

'standard_price': fields.float('Cost', write=['base.group_sale_manager'], read=['base.group_user']),

Suppose, here i give you example of standard price in this i give read right to 'base.group_user' and for write rights give to sales manager so, now you can restrict it by only sales manager can update cost price and the rest of user can only see but not rights to update.

And for invisible particular field you can use groups in xml file also.
So, you can achieve field level security as well as xml security to hide.

<field name="standard_price" groups="base.group_sale_manager"/>

We hope it will useful to you.



  1. I have NN module that lists an array, I want to make in the MM module module list in NN automatically when I save, the code like this:

    def write(self, cr, uid, ids, vals, context=None):
    result= super(krs,self).write (cr, uid, ids, vals, context=None)
    kurikulum=self.pool.get('master.kurikulum'), uid,[('prodi_id','=',, ('semester','=',k.semester),('tahun_ajaran','=',k.tahun_ajaran)])
    import pdb;pdb.set_trace()
    for mk in kur.kurikulum_detail_ids:
    krs_detail.write (cr, uid, ids, {'krs_id':ids,'kurikulum_ids':mk_ids}, context=None)
    return {'values':mk_ids}

    but it not work,,anyone can help me.....
    sorry is my english language is not good :)

  2. Tried "'standard_price': fields.float('Cost', write=['base.group_sale_manager'], read=['base.group_user'])", not working, can you help me please