[FIX] website, test_website: clear menu cache correctly
[This commit] fixed an issue with the menu cache. Unfortunately, during the forward port, we missed updating the cache key according to what has been done in [this other commit]. This commit updates the cache key and improves the test. Steps to reproduce the bug fixed by this commit: - Render a website without a record URL in the menu (to the cache) - Edit the website's menu - Add a link to a product page (e.g., customizable-desk) - Add a link to another product (e.g., chair-floor-protection) - Save the menu - Click on the menu link to go to customizable-desk => At this point, the active menu element is correct - Click on the menu link to go to chair-floor-protection => The active menu element does not update This issue does not occur if there is a record like URL in the menu before the first render. [This commit]: https://github.com/odoo/odoo/commit/970c173530e5523d0e3242ad84dae6fe5e332d68 [this other commit]:https://github.com/odoo/odoo/commit/595aa248433246959a5fa9288e477091701c6a35 opw-3694651 opw-3750925 opw-3781668 closes odoo/odoo#159464 X-original-commit: 9b5647f2951cdd7bde214f860b5ea95d42d2a501 Signed-off-by: Romain Derie (rde) <rde@odoo.com> Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
This commit is contained in:
@@ -21,6 +21,13 @@ class TestWebsiteMenu(HttpCase):
|
||||
controller_url = '/test_website/model_item/'
|
||||
website = self.env['website'].browse(1)
|
||||
|
||||
# First render to fill the cache.
|
||||
with MockRequest(self.env, website=website, url_root='', path=f"{controller_url}{records[0].id}"):
|
||||
html.fromstring(self.env['ir.qweb']._render('test_website.model_item', {
|
||||
'record': records[0],
|
||||
'main_object': records[0],
|
||||
}))
|
||||
|
||||
self.env['website.menu'].create([{
|
||||
'name': records[0].name,
|
||||
'url': f"{controller_url}{records[0].id}",
|
||||
|
||||
@@ -189,7 +189,7 @@ class Website(models.Model):
|
||||
def _get_menu_ids(self):
|
||||
return self.env['website.menu'].search([('website_id', '=', self.id)]).ids
|
||||
|
||||
@tools.ormcache('self.env.uid', 'self.id')
|
||||
@tools.ormcache('self.env.uid', 'self.id', cache='templates')
|
||||
def is_menu_cache_disabled(self):
|
||||
"""
|
||||
Checks if the website menu contains a record like url.
|
||||
|
||||
Reference in New Issue
Block a user