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

convert_field_to_html: Translatable fields #334

Open pedrobaeza opened 1 year ago

pedrobaeza commented 1 year ago

There's a problem with the method convert_field_to_html, as it doesn't handle correctly translatable fields.

This method makes simple SQL queries over SQL contents, but on translatable fields < v16, this should touch also ir.translation rows corresponding to each record. But for implementing any sort of this, there's not enough information passed through arguments, as we are passing the table and the field name, but not the model name (which can't be reversed out of the table name, as not all _ may be converted to .).

We also need to modify it to handle JSON translations for >=v16.

Should we change the API for the method? Leave it as is and handle only v16+?

gdgellatly commented 9 months ago

Well I think it should be easy enough to do both.

For v16+ are we not just dumping to a dict, do each value, converting back and writing? And for the old EAV style, we can do out of band anyway. I think there is enough information because what we know for sure is 1. It will either be a . or _ and 2. There are no duplicates. Therefore a SELECT src, value FROM ir_translation WHERE name like '<table_name>,<field>' ... instead of = and the _ in table name become placeholders.

aryanfanid commented 8 months ago

This might help: https://github.com/OCA/openupgradelib/pull/358/files