Odoo Help

Welcome!

This community 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.

0

how to disable fields multiple fields (Group) with a checkbox ? Help

By
Ali Khan
on 4/17/14, 9:34 AM 1,579 views

I need to hide multiple fields in my form , actually i want the whole group to be invisible when the checkbox is unchecked

0

Nehal

--Nehal--
2090
| 5 2 8
Ahmadabad, India
--Nehal--
Nehal
On 4/17/14, 9:40 AM

Hi,

Try to do like following:

in py file:

def onchange_child_attending_school(self, cr, uid, ids, child_attending_school=False, context=None):
        if child_attending_school:
            return {'value': {'boolean': True}}     
        else:
            return {'value': {'boolean': False}}

in xml file:

<field name="child_attending_school" on_change="onchange_child_attending_school(child_attending_school)/> 
<group string="Education" colspan="4" col="6" attrs="{'invisible':[('boolean', '=', False)]}"> 
      <field name="education_level"/> 
     <field name="class"/> 
     <field name="name_of_school"/>
     <field name="residence"/> 
     <field name="school_address"/>
     <field name="name_of_class_teacher"/> 
     <field name="school_telephone"/> 
</group>

i did try that ,,, but it didn't work... :( <field name="child_attending_school"/>
<group string="Education" colspan="4" col="6" attrs="{'invisible':[('child_attending_school', '=', False)]}"> <field name="education_level"/> <field name="class"/> <field name="name_of_school"/> <field name="residence"/> <field name="school_address"/> <field name="name_of_class_teacher"/> <field name="school_telephone"/> </group>

Ali Khan
on 4/17/14, 10:40 AM

Do you want to hide the group on onchange of child_attending_school?

Nehal
on 4/17/14, 10:43 AM

no i want to hide the group when the child is not attending school ..

Ali Khan
on 4/17/14, 10:44 AM

I did it , time ago , with the attrs ... but now i forgot how i did it last time , and its really annoying :D

Ali Khan
on 4/17/14, 10:53 AM

i have edited my answer. Add one boolean field and try that one.

Nehal
on 4/17/14, 11:00 AM

AttributeError: 'sna.orphan' object has no attribute 'onchange_child_attending_school'

Ali Khan
on 4/17/14, 11:08 AM

Have you restarted the server?

Nehal
on 4/17/14, 11:19 AM

it give me that error on the change event of 'onchange_child_attending_school', so i think restart services wont make a difference

Ali Khan
on 4/17/14, 11:44 AM

You should restart the server for affecting changes of py file and need to update that module to affect changes of xml file.

Nehal
on 4/18/14, 2:12 AM

Hi nehal, how can i do this for single field.. my scenario is,, when a admin confirm(check box is checked),, marks field has to disable/could not be edited.

joshi
on 4/20/15, 3:40 AM

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/17/14, 9:34 AM
Seen: 1579 times
Last updated: 3/16/15, 8:10 AM