Skip to Content
Menu
This question has been flagged
1 Reply
13038 Views

In register payment wizard , I added 2 fields. I want to make fields invisibles according to 'move_type', using :   
attrs='{"invisible":[('move_type', '=' ,'in_invoice')]}'

 attrs='{"invisible":[('move_type', '=' ,'out_invoice')]}'


if move_type == 'in_invoice' --> field1 : invisible

if move_type == 'out_invoice' --> field2 : invisible


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

  <field name="name">account.payment.register.form.inherit.payment.test</field>

  <field name="model">account.payment.register</field>

  <field name="inherit_id" ref="account.view_account_payment_register_form"/>

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

      <xpath expr="//group/field[@name='communication']" position="after">

          <field name="field1"/>

          <field name="field2"/>

       </xpath>

 </field>

</record>


How can I do it ? Thanks.

Avatar
Discard

I don't know what problem you're having because by using 

<field name="field1" attrs="{'invisible': [('move_type',  '=', 'in_invoice')]}" />

<field name="field2" attrs="{'invisible': [('move_type',  '=', 'out_invoice')]}" />

It should have worked. But if you're trying to change the visibility of a field which is already in view that you're inheriting you may want to use 

<field name="field1" position="attributes">

    <attribute name="attrs">[('move_type', '=', 'in_invoice')]</attribute>

</field>

Can you specify more about the problem here.

Best Answer

Hi,

Please try the below code,

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

      <field name="name">account.payment.register.form.inherit.payment.test</field>

      <field name="model">account.payment.register</field>

      <field name="inherit_id" ref="account.view_account_payment_register_form"/>

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

          <xpath expr="//group/field[@name='communication']" position="after">

              <field name="field1" attrs="{'invisible': [('move_type',  '=', 'in_invoice')]}" />

            <field name="field2" attrs="{'invisible': [('move_type',  '=', 'out_invoice')]}" />

           </xpath>

     </field>

</record>


or refer this link

https://www.odoo.com/forum/help-1/how-to-make-a-field-invisible-based-on-condition-in-xml-139634


Thanks

Muhammed Ali M - iWesabe

Avatar
Discard
Related Posts Replies Views Activity
1
Feb 21
7075
1
Dec 22
2712
0
Dec 20
50
0
Dec 15
12185
2
Aug 24
5007