Odoo Help


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

on 5/7/13, 8:40 AM 964 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


Andreas Maertens

--Andreas Maertens--
Andreas Maertens
| 5 5 7
Finsterwalde, Germany
--Andreas Maertens--

I develop odoo8.0 modules

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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.


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)


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