Odoo Help


This community 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.


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

Fabien M
on 6/15/16, 10:55 AM 308 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 2 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)


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