This question has been flagged
2 Replies
3827 Views

I have a big problem, a user exported translation for 10+ modules (17000+ translations), then he imported it on a few odoo instances. Now when you want to load a language with  Overwrite Existing Terms it throws ERROR:

psycopg2.ProgrammingError: ON CONFLICT DO UPDATE command cannot affect row a second time

HINT: Ensure that no rows proposed for insertion within the same command have duplicate constrained values.

I've updated odoo 12 to the latest version from git. Checked every custom modules translation file that thy are for odoo 12 and that there are no duplicates. I've even tried to add DISTINCT to the SQL that are in ir_translation.py. Cannot find the table tmp_ir_translation_import to check and remove the duplicated records. If I found the table I don't even know how to find the duplicated records.


Any suggestion how to fix this would be greatly appreciated!


FULL ERROR:

Error:
Odoo Server Error

Traceback (most recent call last):
  File "/opt/odoo/odoo12/odoo/http.py", line 656, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo12/odoo/http.py", line 314, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/opt/odoo/odoo12/odoo/tools/pycompat.py", line 87, in reraise
    raise value
  File "/opt/odoo/odoo12/odoo/http.py", line 698, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo12/odoo/http.py", line 346, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo12/odoo/service/model.py", line 98, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo12/odoo/http.py", line 339, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo/odoo12/odoo/http.py", line 941, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo12/odoo/http.py", line 519, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo12/addons/web/controllers/main.py", line 966, in call_button
    action = self._call_kw(model, method, args, {})
  File "/opt/odoo/odoo12/addons/web/controllers/main.py", line 954, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/odoo12/odoo/api.py", line 759, in call_kw
    return _call_kw_multi(method, model, args, kwargs)
  File "/opt/odoo/odoo12/odoo/api.py", line 746, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/odoo12/addons/website/wizard/base_language_install.py", line 25, in lang_install
    action = super(BaseLanguageInstall, self).lang_install()
  File "/opt/odoo/odoo12/odoo/addons/base/wizard/base_language_install.py", line 36, in lang_install
    mods.with_context(overwrite=self.overwrite)._update_translations(self.lang)
  File "/opt/odoo/odoo12/odoo/addons/base/models/ir_module.py", line 890, in _update_translations
    self.env['ir.translation'].load_module_terms(mod_names, filter_lang)
  File "/opt/odoo/odoo12/addons/website/models/ir_translation.py", line 11, in load_module_terms
    res = super().load_module_terms(modules, langs)
  File "/opt/odoo/odoo12/odoo/addons/base/models/ir_translation.py", line 811, in load_module_terms
    tools.trans_load(self._cr, base_trans_file, lang, verbose=False, module_name=module_name, context=context)
  File "/opt/odoo/odoo12/odoo/tools/translate.py", line 1016, in trans_load
    result = trans_load_data(cr, fileobj, fileformat, lang, verbose=verbose, module_name=module_name, context=context)
  File "/opt/odoo/odoo12/odoo/tools/translate.py", line 1160, in trans_load_data
    irt_cursor.finish()
  File "/opt/odoo/odoo12/odoo/addons/base/models/ir_translation.py", line 156, in finish
    """ % (self._model_table, self._table))
  File "/opt/odoo/odoo12/odoo/sql_db.py", line 148, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/odoo/odoo12/odoo/sql_db.py", line 225, in execute
    res = self._obj.execute(query, params)
psycopg2.ProgrammingError: ON CONFLICT DO UPDATE command cannot affect row a second time
HINT:  Ensure that no rows proposed for insertion within the same command have duplicate constrained values.
Avatar
Discard
Author Best Answer

The problem was the OCA website_legal_page module. Checked all the translation files and didn't see any same msgid. So then I just added logging in ir_translation.load_module_terms method to log module_name and website_legal_page was the last one before crash. Deleted its i18n dir and now it works. 

Odoo could at least had better logging that would write the modules name. 

Avatar
Discard
Best Answer

need some karma pls

Avatar
Discard