OCA / openupgradelib

A library with support functions to be called from Odoo migration scripts.
GNU Affero General Public License v3.0
85 stars 171 forks source link

[FIX] migrate_translations_to_jsonb: avoid ir_translation terms cleanup #374

Closed chienandalu closed 2 months ago

chienandalu commented 2 months ago

We're making use of core's _get_translation_upgrade_queries which aside from provide the proper queries to upgrade the translated fields to the new json structure tries to cleanup the former ir_tanslation records.

In OpenUpgrade we try to keep historic info after migration so we're able to quickly react to possible inconsistencies.

cc @Tecnativa TT49615

chienandalu commented 2 months ago

There's a limitation here as the core method executes a query inside the method that expects the table ir_translation to be renamed as _ir_translation... so we we should do it in base pre-migration to be able to use it: https://github.com/OCA/OCB/blob/1e74b85c260fc0c6d15e7e4e13d9afcb9c2e9909/odoo/tools/translate.py#L1616-L1631

pedrobaeza commented 2 months ago

I recommend then that this method renames the table before, and restores it after.

pedrobaeza commented 2 months ago

Now that I see the diff, why previous approach replacing inside the query didn't serve?

chienandalu commented 2 months ago

See the code I linked in my previous comment. There's a query execution inside the method that we can't change

pedrobaeza commented 2 months ago

OK, understood

@marielejeune FYI