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

Don't show a form when i check a chekbox

By
Coralie Cardon
on 2/2/16, 3:38 AM 571 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 ! 

2

Atul Arvind

--Atul Arvind--
1854
| 3 3 5
India
--Atul Arvind--

Hello, 

I am odoo Enthusiast/Consultant from Baroda, Gujarat, India. Working with odoo from v5 to v9 and other opensource technology since 4+ years. Having Strong Expertise in

Requirement gathering & Gap Analysis

Odoo Development

Odoo Customization

Odoo Training

Odoo Integration

Server Administration

Odoo Migration

Implementation

I am also active on StackOverflow.

or 


Atul Arvind
On 2/2/16, 6:37 AM

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.

0

Jignesh Mehta

--Jignesh Mehta--
2087
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 2/2/16, 6:13 AM

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,

how?

Atul Arvind
on 2/2/16, 6:39 AM

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)

BHC SPRL, Coralie Cardon
on 2/2/16, 7:28 AM

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

Jignesh Mehta
on 2/2/16, 7:38 AM

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 ?

BHC SPRL, Coralie Cardon
on 2/2/16, 7:42 AM

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

Jignesh Mehta
on 2/2/16, 7:45 AM

ok but if the form is like that :

if i put the attributes in the groupes the footer is visible
BHC SPRL, Coralie Cardon
on 2/2/16, 7:49 AM
BHC SPRL, Coralie Cardon
on 2/2/16, 7:51 AM

form - group - footer - /form *

BHC SPRL, Coralie Cardon
on 2/2/16, 7:52 AM

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

Jignesh Mehta
on 2/2/16, 7:58 AM

I have the same error :(

BHC SPRL, Coralie Cardon
on 2/2/16, 8:08 AM

can you post your code with the error msg ?

Jignesh Mehta
on 2/2/16, 8:32 AM

check_box_form field should be in your form view.

Atul Arvind
on 2/2/16, 11:08 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

1 follower(s)

Stats

Asked: 2/2/16, 3:38 AM
Seen: 571 times
Last updated: 2/2/16, 6:37 AM