İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
2878 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç

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.

İlgili Gönderiler Cevaplar Görünümler Aktivite
Odoo 16 Çözüldü
1
Ara 22
4177
8
Oca 25
6749
3
Mar 24
2918
1
Tem 23
2369
2
May 25
5361