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.


How to print the string value of a selection field instead of its key

babis peroukas
on 10/28/13, 3:25 AM 2,783 views


I have two more questions (I dont want to spam post questions):

1) How can can I recieve the string value of a selection field ( [('1','Our base'), ('2','Client's base')] )? In this case I want to print for example "Our base". In my report I use [ o.x_loadbase ]] (the name of the field) but it prints just the key (1) intead of the value (Our base). Even if I send it to another model (its in the sale.order and i send it to account.invoice) it shows the key value.

2) Is there any way to assign a journal and sequence to the cancelled invoices?


On 8/7/14, 4:27 AM

Easier and more flexible is [ o.x_loadbase == '1' and 'Our base']

David Warner
On 10/28/13, 4:14 AM

Add these lines in your RML file where you are trying to fetch Value of your field (i.e.selection field).

<para style="terp_header">Our Base[[ ((o.x_loadbase == '1') or removeParentNode('para')) and '' ]]</para>

<para style="terp_header">Client's Base[[ ((o.x_loadbase == '2') or removeParentNode('para')) and '' ]]</para>

And also add one more line in Your RML file in header

<paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="7.0" leading="15" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>

It"ll, Surely Solve your problem

Hello and thanks for the answer, but isnt there any other way so I dont do this for every selection field I create? Also I want those values to pass from a model to another (from sale.order to account.invoice) so I ve put the fields in sale.order vals, but they are just passed with their keys and not with theit strings. In this case the printed field is not selection type... its char. Thanks :)

babis peroukas
on 10/28/13, 4:52 AM

May I know all your selection values are constant throughout?

David Warner
on 10/30/13, 9:03 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

0 follower(s)


Asked: 10/28/13, 3:25 AM
Seen: 2783 times
Last updated: 3/16/15, 8:10 AM