تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
14433 أدوات العرض

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>
الصورة الرمزية
إهمال
أفضل إجابة

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

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

الصورة الرمزية
إهمال
الكاتب

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>

الكاتب

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.

الكاتب

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?

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
أكتوبر 22
7
1
يونيو 23
3211
0
نوفمبر 15
5306
1
سبتمبر 21
5969
2
يوليو 21
2821