[FIX] core: fix cached translations

before this commit:
translations updated by `update_field_translation` api cannot be detected by
t-cache and some cached data whose model overrides `write` with an extra
'clear_caches()'

Step to reproduce:
- Create a mega menu, select any template, `Odoo Menu` for the example
- Install another language on the website
- Go to the translated version of your website and enter translate mode
- Change "Camera" in the mega menu to something else
- Save

The change won't be replicated, looking like it did nothing.
From there, removing or adding `edit_translations=1` in the URL will
use different cache version of the page's views and you will see the
outdated value on one and the correct on the other one.

after this commit:
`update_field_translation` will call `write`
it does the following 4 important things
1. mark field as modified
2. execute logics in the override `write` method
3. update write_date if needed to support t-cache

opw-3305117

X-original-commit: 2beb466668e4eb80d7c3ca3947445fb1cb141cff
Part-of: odoo/odoo#135277
This commit is contained in:
Chong Wang (cwg)
2023-09-13 12:19:10 +00:00
parent c71b571b68
commit 506d0cc4ec
7 changed files with 79 additions and 16 deletions
+1
View File
@@ -1397,6 +1397,7 @@ class TranslationImporter:
self.model_translations.clear()
env.invalidate_all()
env.registry.clear_cache()
if self.verbose:
_logger.info("translations are loaded successfully")