From f294ccdb032df7bec5271a426a924b0865a6c079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 11 Oct 2019 10:20:40 +0000 Subject: [PATCH] [FIX] website: ensure the cache of the pages stay consistent with COW This is necessary when writing view fields from a page record because the generic page will put the given values on its cache but in reality the values were only meant to go on the specific page. Invalidate all fields and not only those in vals because other fields could have been changed implicitly too. Pr: #37363 X-original-commit: 83f9a3e2608db34a319b985271d73f7de5bc73a1 --- addons/website/models/ir_ui_view.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 7c92478d231..628869b6b94 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -64,6 +64,16 @@ class View(models.Model): super(View, view).write(vals) continue + # Ensure the cache of the pages stay consistent when doing COW. + # This is necessary when writing view fields from a page record + # because the generic page will put the given values on its cache + # but in reality the values were only meant to go on the specific + # page. Invalidate all fields and not only those in vals because + # other fields could have been changed implicitly too. + pages = view.page_ids + pages.flush(records=pages) + pages.invalidate_cache(ids=pages.ids) + # If already a specific view for this generic view, write on it website_specific_view = view.search([ ('key', '=', view.key),