[FIX] website: perf - prefetch website.menu's mega_menu_content

Since this field is not sanitized, it is safe (perf wise) to prefetch it.
It should not be CPU heavy, plus whenever we access a `website.menu`, it is
most likely we will read that field.

with following structure, 5 SQL queries will be avoided:
- Top menu
  - Home
  - Contact us
    - Sub Contact us
      - Sub Sub Contact us

Related to #47257
task-2211013

X-original-commit: 20cddcd899e7a119fa9f365e62527499f8e5ff7d
This commit is contained in:
Sébastien Theys
2020-03-19 15:37:44 +00:00
committed by Romain Derie
parent f95af92ae3
commit 1d981f22f3
+1 -1
View File
@@ -44,7 +44,7 @@ class Menu(models.Model):
group_ids = fields.Many2many('res.groups', string='Visible Groups',
help="User need to be at least in one of these groups to see the menu")
is_mega_menu = fields.Boolean(compute=_compute_field_is_mega_menu, inverse=_set_field_is_mega_menu)
mega_menu_content = fields.Html(translate=html_translate, sanitize=False)
mega_menu_content = fields.Html(translate=html_translate, sanitize=False, prefetch=True)
mega_menu_classes = fields.Char()
def name_get(self):