diff options
| author | Xavier-Do <xdo@odoo.com> | 2019-10-17 09:34:23 +0000 |
|---|---|---|
| committer | fw-bot <otis@odoo.com> | 2019-10-17 17:10:06 +0000 |
| commit | fbfae7efc42b283dea3b0f6a83cc8a867b8a8a6d (patch) | |
| tree | 6f1aa4dfa1bb9bcf69a3cf58679e00e7b200b76c /odoo/addons/base/models/assetsbundle.py | |
| parent | d65fcfecb6424d1e99df56611e374f8a97682c3d (diff) | |
[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>
Diffstat (limited to 'odoo/addons/base/models/assetsbundle.py')
| -rw-r--r-- | odoo/addons/base/models/assetsbundle.py | 10 |
1 files 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 |
