Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
2803 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää

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.

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
Odoo 16 Ratkaistu
1
jouluk. 22
4081
8
tammik. 25
6633
3
maalisk. 24
2837
1
heinäk. 23
2281
2
toukok. 25
5241