Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
2846 Visninger

In previous versions we had the ir.translation model to manage the translations.

Now in version 16.0, how can I update all my product's name using python, to have all translations (en_US, pt_BR, ...) being the same?

for example, the current situation:

{"en_US": "Table (copy)", "pt_BR": "Chair"}

and the desired situation:

{"en_US": "Chair", "pt_BR": "Chair"}

thanks

Avatar
Kassér
Bedste svar

Hello Guilherme !

Thank you for your question ! With the Odoo shell, you can use the following to write (or read) that product in the language of your choice

product_id = 1990904  # Your product_id goes here
product = env["product.template"].browse(product_id)
product.with_context({"lang": "en_US"}).name = "Chair"

(Don't forget to commit your changes with env.cr.commit() once you want to save your changes)

You can then double check if the change is correct by using 

product.with_context({"lang": "en_US"}).name

Which will return you "Chair"


Hope this helps ! :)


EDIT (thanks Ray), you can also search for your product as such

product = env["product.template"].search([("name", "=", "Table (copy)")])

in case you are unsure of its id, since product.product ids are different than product.template ids

Avatar
Kassér

Anyone doing this, please don't mix up the product.product with the product.template.

Things you see on Sales Orders, Invoices, Warehouse Transfers are "product.product" records so their ID would not be used to find the corresponding product.template.

Related Posts Besvarelser Visninger Aktivitet
Odoo 16 Løst
1
dec. 22
4131
8
jan. 25
6690
3
mar. 24
2878
1
jul. 23
2341
2
maj 25
5304