Help

3

How to set employee field, some are readonly and some for editable

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

Avatar
Discard
1 Answer
1
Best Answer

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( ...)
Avatar
Discard