Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
2630 Переглядів

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

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити

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 Відповіді Переглядів Дія
Odoo 16 Вирішено
1
груд. 22
3920
8
січ. 25
6430
3
бер. 24
2664
1
лип. 23
2090
2
трав. 25
4969