Mass modification of product names

I have to make a modification to the name of the products on a large quantity of product. We processed the new product names with an calc file.

I’m thinking of doing the update in SQL using a temporary table.
Since the product name is a translatable field, I also need to do a SQL update in the ir_translation table for all languages. Translations will be managed later via the tryton GUI interface.

Steps:

Importing the excel file into a temporary table: product_to_update
Column: id,code,new_name

update product_template :

update product_template pt set name = p_to_up.new_name
from product_to_update as p_to_up
where pt.id=p_to_up.id

update ir_translation :

update ir_translation ir_t set
src=p_to_up.new_name,
value=p_to_up.new_name,
fuzzy = false
from product_to_update as p_to_up
where ir_t.res_id= p_to_up.id and
name = 'product.template,name'

Is there another approach to accomplish this?
should I plan another operation regarding synchronization in the ir_translation table?

As you have the ID, why not using CSV import to update the field.
Also you can import the other language version using the column name name:lang=fr (but this is not available from the client).

I didn’t understand that the “Import CVS” option also performs the update. I tested and it works very well (you just have to be careful with the column names). Thanks for the information.

I didn’t understand the information “this is not available from the client”. Which CVS import option should we use to introduce the name:lang:fr columns? THANKS

You can update any record on the database usig CSV import export.
To do so you should export the data on tryton and include the ID field (so tryton can latter know which records needs to be updated).

Then you just update all the values on the CSV using your favourite spreedsheet software and then use the CSV import feature to upadte the value. Tryton will update the field value of all records with the matching ID.

1 Like

The clients do not understand this syntax (for now).
But you can call ModelStorage.import_data with such header.

2 Likes