[IMP] base: avoid invalidate cache on first assets

Assets bundle creation will try to find previous version of assets and unlink them.
This needs to invalidate ormcache to notify other workers.

Since assets are never commited during test, assets will be generate at each request if request is
not commited (cursor closed) whtch is the case with 404.

Invalidating the orm cache only when a previous attachement was existing will help to
mitigate the problem, and slightly improve HTTPCases test speed.

closes odoo/odoo#38979

X-original-commit: d4d63549e1b31e3f3c97a2b91155023dbac62847
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
Xavier-Do
2019-10-17 17:10:06 +00:00
committed by fw-bot
parent d65fcfecb6
commit fbfae7efc4
+7 -3
View File
@@ -230,11 +230,15 @@ class AssetsBundle(object):
('url', '=like', url),
'!', ('url', '=like', self.get_asset_url(unique=self.version))
]
attachments = ira.sudo().search(domain)
# avoid to invalidate cache if it's already empty (mainly useful for test)
# force bundle invalidation on other workers
self.env['ir.qweb'].clear_caches()
if attachments:
attachments.unlink()
# force bundle invalidation on other workers
self.env['ir.qweb'].clear_caches()
return ira.sudo().search(domain).unlink()
return True
def get_attachments(self, type, ignore_version=False):
""" Return the ir.attachment records for a given bundle. This method takes care of mitigating