camptocamp / anthem

make your odoo scripts sing
GNU Lesser General Public License v3.0
26 stars 28 forks source link

[12.0] update_translations with overwrite=True doesn't work #61

Open yankinmax opened 3 years ago

yankinmax commented 3 years ago

Here https://github.com/camptocamp/anthem/blob/e067afb678c1c036e90949c5e39b9df104b45661/anthem/lyrics/modules.py#L23-L44 we specify overwrite=True, so existing translation should be overwritten. While debugging here (where it's supposed to be upserted) https://github.com/odoo/odoo/blob/5d40023eaf9b3c25941429e7fac266722780846d/odoo/addons/base/models/ir_translation.py#L137 always have self._overwrite=False.

sebalix commented 3 years ago

The calls seems to be:

  1. ir.module.module._update_translations
  2. ir.translation.load_module_terms
  3. tools.translate.trans_load Could you check the context in each step?

EDIT: The issue is maybe in the fourth call:

  1. tools.translate.trans_load_data: the context parameter is not propagated toir.translation method calls it seems...
yvaucher commented 3 years ago

BTW for V14 this change broke our implementation here

https://github.com/odoo/odoo/commit/ac63556e239ab03c42384477385f003c7477287b

The overwrite context key has been replace by an argument. It is present on module's _update_translation() method: https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/models/ir_module.py#L908

Thus for v14 we will want to call:

Module._update_translation(overwrite=overwrite)