Skip to Content
Menu
This question has been flagged
1 Reply
6066 Views

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.

Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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>

Author

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 !

Author

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

Author

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

Related Posts Replies Views Activity
6
May 24
105602
0
Jan 24
407
2
Oct 20
1439
0
Jul 20
2919
3
Jan 20
6977