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

Hi, Im trying to hide the field called vat if the field supplier is true, but I don't know what I'm doing wrong

Here is my code, I'm able to hide the field but can't do it with the if condition on the supplier field.

Thank you in advance

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="view_new_sale_form">
<field name="name">res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='vat']" position="attributes">
<t t-if="docs.supplier == true">
<attribute name="invisible">True</attribute>
</t>
</xpath>
</field>
</record>
</odoo>

Correct code after answers:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="view_new_sale_form">
<field name="name">res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='vat']" position="attributes">
<attribute name="attrs">{'invisible': [('supplier','=',True)]}</attribute>
</xpath>
</field>
</record>
</odoo>
Avatar
Discard
Best Answer

Correct answer from comments:
<attribute name="attrs">{'invisible': [('supplier','=',True)]}</attribute>

Original Answer:
<t t-if="docs.supplier"> remove == True

Avatar
Discard
Author

Thank you for your answer, I tried like and it hide the field vat but even if the docs.supplier is false the field vat still hiden. You know why this could be happend?

Do like this

<t t-if="docs.supplier">

<attribute name="invisible">1</attribute>

</t>

Author

Trying that doesn't work either, It still hide the field vat no matter is supplier is true or false, maybe the t t-if is not supposed to be inside the xpath, but if I used it outside doesn't find the field supplier maybe because is in a page, thank you for answer

Try this without t tags

<attribute name="attrs">{'invisible': [('supplier','=',True)]}</attribute>

use docs.supplier without docs. Better print supplier and check what value it has.

Author

Thank you very much the line <attribute name="attrs">{'invisible': [('supplier','=',True)]}</attribute> works perfectly, I'm going to practice more on this kind of problems, you reccomend some site or from the docs is enough?

Related Posts Replies Views Activity
0
Oct 22
7
1
Jun 23
1824
0
Nov 15
4359
1
Sep 21
5131
2
Jul 21
1902