Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yankinmax opened this issue Jul 23, 2021 · 2 comments
Open

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

yankinmax opened this issue Jul 23, 2021 · 2 comments

Comments

@yankinmax
Copy link
Member

Here

def update_translations(ctx, module_list, overwrite=False):
""" Update translations from module list"""
if not isinstance(module_list, list):
raise AnthemError(u"You have to provide a list of "
"module's name to update the translations")
if overwrite:
ctx.log_line(
u'All previous translations will be dropped for requested addons'
)
ir_module = ctx.env['ir.module.module']
if hasattr(ir_module, 'update_translations'):
# Odoo version <= 10.0
method_name = 'update_translations'
else:
# Odoo version >= 11.0
method_name = '_update_translations'
domain = [('name', 'in', module_list)]
mods = ctx.env['ir.module.module'].search(domain)
ctx.log_line('Reloading translations for %s' % str(module_list))
mods.with_context(overwrite=overwrite)
getattr(mods, method_name)()

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
Copy link
Member

sebalix commented Jul 23, 2021

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
Copy link
Member

BTW for V14 this change broke our implementation here

odoo/odoo@ac63556

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants