Odoo Help

3

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

By
ClueLogics Technologies Pvt. Ltd.
on 5/7/13, 8:40 AM 1,224 views

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

1
Andreas Maertens
On 5/14/13, 8:49 AM

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

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 5/7/13, 8:40 AM
Seen: 1224 times
Last updated: 3/16/15, 8:10 AM