Skip to Content
Menu
This question has been flagged
3 Replies
7455 Views

Hi,

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.


Regards,

Scot.


Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

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

@api.one

def get_sale_state(self):

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

    return state_list[self.state]


And in your email template call it as usual:

${object.get_sale_state()}

Avatar
Discard
Best Answer

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

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

% endif
</code>

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

Avatar
Discard