Odoo Help


How to get value from selection field in Email Template

on 3/24/15, 4:50 AM 1,506 views


I am creating a template for a class (say sale.order), in which I have a selection field (state). While I am trying to fetch value of state using ${object.state}, I am getting the "key" but not the "value" of the selection field. How can I get the value of selection. Please kindly help me. Thanks in advance.




Ameera PP

--Ameera PP--
--Ameera PP--

Ameera PP
On 11/1/16, 6:52 AM

you will get only key values here. You can check in the report if ${object.state} value is 'xxx' , then you can print XXX

Mohamed Essakali
On 5/6/18, 7:35 PM

You can simply add a method and call it like this ( the code is not tested):


def get_sale_state(self):

     state_list = {'draft': 'Quotation', ...}

    return state_list[self.state]

And in your email template call it as usual:


On 3/24/15, 5:18 AM

Not sure on how to get the field_val. But a workaround could be using if statements
% if object.state in ('draft'):  draft

% endif % if object.state in ('paid'):  paid

% endif

Something like this should work. Although the only if statements in mail templates i could find at this moment are checking if the variables are set. But I figure this would work. I couldn't test this, as my mailserver on my testenv is not configured

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

1 follower(s)


Asked: 3/24/15, 4:50 AM
Seen: 1506 times
Last updated: 5/6/18, 7:35 PM