Skip to Content
Menu
This question has been flagged
2 Replies
5526 Views

Hello !

I have a form, and when i have checked my checkbok i would like odoo don't show this form. 

How can i do ? 

What is the codee to use ? 

Thanks ! 

Avatar
Discard
Best Answer

you can use the attrs in XML in order to make fields, group, notebook, page invisible, read-only & required. Here is a piece of code that might help you.

  <field name="checkbox_field" string='Make Group Invisible?'  />
  <group name="my group" attrs="{'invisible' : [('checkbox_field', '=', True)]}">
<field name='field1'/>
<field name='field2'/>
</group>

when you check the check box it will make the whole group invisible.

Avatar
Discard
Best Answer

Hello Coco,


For don't show a form when click, you need to add attrs to the form view.


For Ex:-

<record id="unique_id" model="ir.ui.view">

    <field name="name">name</field>

    <field name="model">model_name</field>

    <field name="arch" type="xml">

        <form>

              <group name="field_group" attrs="{'invisible' : [('your_checkbox_name', '=', True)]}">

                    <field name="field1"/>

                     <field name="field2"/>

              </group>

         </form>

     </field>

</record>


Hope, it will help you.

Thanks,

Avatar
Discard
Author

Hello, I have an error :( Uncaught Error: Unknown field check_box_form in domain [["check_box_form","=",true]] http://10.56.8.44:8069/web/static/src/js/framework/data.js:1075 Traceback: Error: Unknown field check_box_form in domain [["check_box_form","=",true]] at Object.compute_domain (http://10.56.8.44:8069/web/static/src/js/framework/data.js:1075:19) at OdooClass.View.extend.compute_domain (http://10.56.8.44:8069/web/static/src/js/views/form_view.js:1151:21) at OdooClass. (http://10.56.8.44:8069/web/static/src/js/views/form_common.js:316:40) at OdooClass.Class.extend.trigger (http://10.56.8.44:8069/web/static/src/js/framework/mixins.js:222:31) at OdooClass._.extend.trigger (http://10.56.8.44:8069/web/static/src/js/framework/mixins.js:272:42) at OdooClass.View.extend.on_form_changed (http://10.56.8.44:8069/web/static/src/js/views/form_view.js:396:14) at Array. (http://10.56.8.44:8069/web/static/src/js/views/form_view.js:365:18) at Array. (http://10.56.8.44:8069/web/static/lib/jquery/jquery.js:3276:89) at fire (http://10.56.8.44:8069/web/static/lib/jquery/jquery.js:3119:58) at Object.self.add [as done] (http://10.56.8.44:8069/web/static/lib/jquery/jquery.js:3165:49)

have you add your field in form view as say by Atul Arvind sir ?

Author

Yes i had add the attributes in the form. But the problem is : when i click on my module i have my form like a pop up. In the configuration of the module you add this check box. The check box isn't in the form. Do you see what i mean ?

Form can't be hide through attrs. You can invisible, readonly and required to notebook, page, fields, groups.

Author

ok but if the form is like that :

if i put the attributes in the groupes the footer is visible
Author

form - group - footer - /form *

May be, you can also add attrs in the footer to invisible it.

Author

I have the same error :(

can you post your code with the error msg ?

check_box_form field should be in your form view.

Related Posts Replies Views Activity
2
May 24
451
2
Dec 23
384
1
Nov 22
1721
0
Jan 21
987
5
Jul 19
3511