Odoo - ORM 从 product.template 中检索翻译后的名称

Odoo - ORM retrieve translated name from product.template

我想从 product.template 中检索名称:

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

如何在 ORM 中获取翻译后的名称?

您可以在上下文中传递语言代码以获取该语言的特定产品名称。在使用之前,请确保该语言已加载到您的服务器中。我对您的代码做了一些更改,以获取德语/Duetsch 语言的产品名称。

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

希望对您有所帮助。 :)