İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
14417 Görünümler

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
Vazgeç
En İyi Yanıt

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

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

Avatar
Vazgeç
Üretici

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>

Üretici

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.

Üretici

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?

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Eki 22
7
1
Haz 23
3195
0
Kas 15
5305
1
Eyl 21
5968
2
Tem 21
2815