How to set employee field some are readonly and some for editable for employee group while other group such as manager and officer all field for editable
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
3594
Views
You can add an conditioned field on your view (invisible="1", readonly="1") relating to a function field in your model. There you can evolve by anything you want and return a string bool or number and so in to evaluate if another field is visible or maybe readonly:
The View:
<field name="write_if_manager" attrs="{'readonly':['|',('is_manager', '==', 'false'),('state','not in','['draft']') ] }/>
<field name="is_manager" invisible="1"/>
The class looks like
class classname(osv.osv):
...
def _is_manager(cr, uid, ids ...
res = {}
for this_id in ids:
if obj_users.has_group(cr, uid, 'MANAGER-GROUPNAME'):
res[this_id] = manager
return res
...
_columns = {
'is_manager':fields.function(_is_manager, type='boolean' ...
'write_if_manager':fields.char( ...)