Odoo Help

Welcome!

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.

1

How to get language name in rml report from partner

By
Tomas Parnarauskas
on 9/4/13, 8:49 AM 1,481 views

Is there a way to get Language name that partner is chosen in rml report? In code I only saw you can get language codes, like en_US. But what if I need to just return name of the Language (like English)? Didn't see that there are any relations with res.lang object. Maybe there is some work around? Or the only way is to customize the module?

0

IBS

--IBS--
1302
| 4 5 8
Tétouan, Morocco
--IBS--

For more informations about IBS, please visit our website at www.ibs-na.com.

For a specific questions, collaboration or help, please send us an email to support@ibs-na.com

IBS
On 9/4/13, 5:59 PM

You can try something like this:

[[ ( o.partner_id.lang == 'en_US' ) and 'English' or 'OtherLang' ]]

Or

<para>[[ ( o.partner_id.lang == 'en_US' ) and 'English' or removeParentNode( 'para' ) ]]</para>
<para>[[ ( o.partner_id.lang == 'fr_FR' ) and 'Français' or removeParentNode( 'para' ) ]]</para>
...

This one is more suited if you have more than 2 languages.

This is sets language. I need to just return name of chosen language.

NOD Baltic, UAB, Tomas Parnarauskas
on 9/5/13, 3:28 AM

Actually it does not work like that. As lang field is not directly related with res.lang object. If you looked in code, you would see that lang field is selection field which uses function, which returns code of language chosen.

NOD Baltic, UAB, Tomas Parnarauskas
on 9/5/13, 8:53 AM

Yes you are right, I updated my answer with something that'll help you achieve what you need

IBS
on 9/5/13, 9:04 AM

I added in 2 possiblities.

IBS
on 9/5/13, 9:06 AM

This is a bit hard coded, but looks like it's the only way now. Thanks.

NOD Baltic, UAB, Tomas Parnarauskas
on 9/5/13, 9:08 AM

If you want to avoid hard coding, you could change the field type of the lang column to be a many2one and have a reference to the language object, that way you can just use o.partner_id.lang.name

IBS
on 9/5/13, 9:15 AM

Yes it's possible, but if this field would be changed, I imagine all other reports that use this field, would stop working properly as they all would need to be modified.

NOD Baltic, UAB, Tomas Parnarauskas
on 9/5/13, 9:22 AM

Yes indeed. Let's see, how about you add a new hidden many2one field that you update with a method mapped to the on_change attribute of the lang field, where you could fill the new field with the language object reference depending on the choice of the user and use it directly in your report.

IBS
on 9/5/13, 9:26 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)

Stats

Asked: 9/4/13, 8:49 AM
Seen: 1481 times
Last updated: 3/16/15, 8:10 AM