Skip to Content
Menu
This question has been flagged
2 Replies
936 Views

I define Translatable field in Odoo

classProductCategory(models.Model): 

   _inherit = "product.category"
    name = fields.Char(translate=True

! "English / deutsch"

now I want to read the data from this field in QWEB or Python file by English or Deutsch!

if I use below form, I can access to user_lang:
env['product.category'].browse(5).name

can you help me?!


env['product.category'].browse(5).name(en)
env['product.category'].browse(5).name(de)

Avatar
Discard
Author Best Answer

Thanks, Sudhir
But I don't know why it is not true on "product.category" model.

env['product.category'].with_context(lang='de_DE').browse(5).name
        >> 40.100 Mobilfunkdatenkarten T-Mobile
env['product.category'].with_context(lang='en_US').browse(5).name
        >> 40.100 Mobilfunkdatenkarten T-Mobile

But in fact they are different!

Avatar
Discard
Best Answer

You need to pass the lang code in the context to have the content in translation.

Ex:

env['product.product'].with_context(lang='nl_BE').browse(5).name


Avatar
Discard
Related Posts Replies Views Activity
4
May 24
10064
1
Apr 24
1561
0
Nov 23
523
1
Sep 23
561
2
Aug 23
2421