Odoo Help


Qweb invoice, how to display one text or another depending on a boolear field ?

Fabien M
on 6/15/16, 10:55 AM 1,023 views


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 if t-field="x_factoring == false">

text 2


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


Jérémy Kersten (jke)

--Jérémy Kersten (jke)--

| 3 3 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 6/15/16, 11:03 AM

maybe you could try t-if :)


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>
<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>


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 t-if="x_affacturage == true">

text 2


Fabien M
on 6/15/16, 11:19 AM

And with smthg like: ???

<div t-if="not x_affacturage">

text 1


<div t-if="x_affacturage">

text 2


Jérémy Kersten (jke)
on 6/15/16, 11:23 AM

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

Fabien M
on 6/15/16, 11:31 AM

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 !

Jérémy Kersten (jke)
on 6/15/16, 11:43 AM

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

Fabien M
on 6/17/16, 4:03 AM

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

Fabien M
on 6/17/16, 9:40 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 6/15/16, 10:55 AM
Seen: 1023 times
Last updated: 6/15/16, 11:29 AM