From fbfae7efc42b283dea3b0f6a83cc8a867b8a8a6d Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Thu, 17 Oct 2019 09:34:23 +0000 Subject: [PATCH] [IMP] base: avoid invalidate cache on first assets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- odoo/addons/base/models/assetsbundle.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/odoo/addons/base/models/assetsbundle.py b/odoo/addons/base/models/assetsbundle.py index 0181bd8a434..0a8131ac989 100644 --- a/odoo/addons/base/models/assetsbundle.py +++ b/odoo/addons/base/models/assetsbundle.py @@ -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