[IMP] website: perf - clear cache only when needed

Before this commit, the cache would always been cleared even if not needed.
Now, we only clear cache when needed.

Util:
Introduced with https://github.com/odoo/odoo/commit/9920f20e4c7753bc17bea71dea3a90f7de687196#diff-1407a8ce197a04eefaefa26c127a4418R327
Changed with 0d5fcdc1c7

task-2211013
This commit is contained in:
Romain Derie
2020-03-26 18:12:47 +00:00
parent a5a57321c7
commit d52c2bbe19
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -119,4 +119,4 @@ class TestWebsitePerformance(UtilPerf):
# assets route /web/content/..
self.url_open('/') # create assets attachments
assets_url = self.env['ir.attachment'].search([('url', '=like', '/web/content/%/web.assets_common%.js')], limit=1).url
self.assertEqual(self._get_url_hot_query(assets_url), 6)
self.assertEqual(self._get_url_hot_query(assets_url), 5)
+2 -1
View File
@@ -318,7 +318,8 @@ class IrHttp(models.AbstractModel):
# We have prefetched some fields of record, among which the field
# 'write_date' used by '__last_update' below. In order to check
# access on record, we have to invalidate its cache first.
record._cache.clear()
if not record.env.su:
record._cache.clear()
record['__last_update']
except AccessError:
return None, 403