Odoo Help

2

2
2 Answers
3
Avatar

Andreas Maertens Germany

--Andreas Maertens--
1037
| 6 6 9
Finsterwalde, Germany
--Andreas Maertens--

I develop odoo8.0 modules

Andreas Maertens Germany
5/14/13, 8:55 AM

Additionally to Francescos Answer you can add functions to validate if a field should be visible by this:

(copied from Francescos link: https://accounts.openerp.com/forum/Help-1/question/13042/)

You can add an invisible field on your view (invisible="1") relating to a function field in your model. There you can evolve by anything you want and return a stringm 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( ...)
2
Avatar

Francesco OpenCode Italy

--Francesco OpenCode--

3949
| 7 8 11
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo Developer. Python lover. Beer addicted.

LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode Italy
5/14/13, 8:40 AM

Use this system

https://accounts.openerp.com/forum/Help-1/question/13042

with readonly parameters instead invisible

2 Comments
Pravitha Qatar
5/14/13, 8:44 AM

sir actualy i want the field to be readonly if state of account.move is 'posted'

Francesco OpenCode Italy
5/14/13, 11:11 AM

<field name="YOUR_FIELD_NAME" attrs="{'readonly':[('state','=','posted')]}">

Ask a Question
Writer
Keep Informed
0 follower(s)
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