Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
14427 Widoki

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>
Awatar
Odrzuć
Najlepsza odpowiedź

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

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

Awatar
Odrzuć
Autor

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>

Autor

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.

Autor

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?

Powiązane posty Odpowiedzi Widoki Czynność
0
paź 22
7
1
cze 23
3204
0
lis 15
5305
1
wrz 21
5968
2
lip 21
2821