M.E.
M.E.

Reputation: 5495

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?

Upvotes: 1

Views: 586

Answers (1)

PyMaster
PyMaster

Reputation: 1174

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. :)

Upvotes: 4

Related Questions