Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
7159 มุมมอง

Hello,

I want to display the payment informations on my invoice Qweb, but these ones depend on the method of payment.

If the invoice is paid with factoring, I wanna display the text 1, if not, I wanna display the text 2.

So I created a boolean field "x_factoring" in invoice.form.

I want to write something like this :


<div if t-field="x_factoring == true">

text 1

</div>


<div if t-field="x_factoring == false">

text 2

</div>


I don't know the exact way to do so thanks to correct me.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

maybe you could try t-if :)


https://www.odoo.com/documentation/8.0/reference/qweb.html


Here a sample


<t t-set='x_field' t-value='bool(1)' />
Value : <t t-esc="x_field and 'TRUE' or 'FALSE'"/>
<div t-if="x_field">My div TRUE</div>
<div t-if="not x_field">My div FALSE</div>
<br/>
<t t-set='x_field2' t-value='bool(0)'/>
Value : <t t-esc="x_field2 and 'TRUE 2' or 'FALSE 2'"/>
<div t-if="x_field2">My div TRUE 2</div>
<div t-if="not x_field2">My div FALSE 2</div>


Rendering:


Value : TRUE
My div TRUE

Value : FALSE 2
My div FALSE 2

อวตาร
ละทิ้ง
ผู้เขียน

Thank you, you get a point ! But it's not working yet, here's exactly my code.

On my invoice, currently both text are displayed.

<div t-if="x_affacturage == false">

text 1

</div>

<div t-if="x_affacturage == true">

text 2

</div>

And with smthg like: ???

<div t-if="not x_affacturage">

text 1

</div>

<div t-if="x_affacturage">

text 2

</div>

ผู้เขียน

It do no longer display both, but only the text 1. Even if the x_affacturage field is checked !

Take a look to my edited answer... and print the value of x_affacturage before to be sure... with <t t-esc="x_affacturage and 'TRUE' or 'FALSE'"/>

It should really works !

ผู้เขียน

Ok, but I still don't understand how to write my final code sorry :(

ผู้เขียน

I resolved my problem though. :) I simply added a new invoice report, with different payment informations ! Thanks a lot

Related Posts ตอบกลับ มุมมอง กิจกรรม
Qweb if-else condition? แก้ไขแล้ว
6
พ.ค. 24
110633
0
ม.ค. 24
1517
Inovice qweb file customisation ver 14 แก้ไขแล้ว
2
ต.ค. 20
2045
0
ก.ค. 20
4388
3
ม.ค. 20
8009