Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
14436 Visninger

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
Kassér
Bedste svar

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

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

Avatar
Kassér
Forfatter

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>

Forfatter

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.

Forfatter

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 Besvarelser Visninger Aktivitet
0
okt. 22
7
1
jun. 23
3214
0
nov. 15
5306
1
sep. 21
5969
2
jul. 21
2822