Search code examples
odoo-10

Odoo - ORM retrieve translated name from product.template


I want to retrieve the name from product.template:

print self.env['product.template'].search([("id", "=", id), ]).name

How do I get translated name in ORM?


Solution

  • You can pass the language code in context to get specific product name in that language. Make sure that language has been loaded in your server before using it. I did some changes in your code to get the product name in German / Duetsch language.

    print self.env['product.template'].with_context({'lang': 'de_DE'}).search([("id", "=", id)]).name
    

    I hope this will help you. :)