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.

..Enjoy..