[FIX] base: faster fill_assets_path

After the previous fix introducing a deepcopy, the pregenerate of the
assets became slower because of the many call to get_manifest (in loop,
recursively)
Since the manifest is immutable here and won't go outside of the call,
we can use the lower level version.

closes odoo/odoo#146602

X-original-commit: acb671f4d1b9c53c9e7d91414e847f26e8026ca3
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
Xavier-Do
2023-12-18 14:34:23 +00:00
parent ff51570aed
commit 3f9bf7da98
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -182,7 +182,7 @@ class IrAsset(models.Model):
# 2. Process all addons' manifests.
for addon in addons:
for command in odoo.modules.module.get_manifest(addon)['assets'].get(bundle, ()):
for command in odoo.modules.module._get_manifest_cached(addon)['assets'].get(bundle, ()):
directive, target, path_def = self._process_command(command)
self._process_path(bundle, directive, target, path_def, asset_paths, seen, addons, installed, bundle_start_index, **assets_params)
@@ -284,7 +284,7 @@ class IrAsset(models.Model):
IrModule = self.env['ir.module.module']
def mapper(addon):
manif = odoo.modules.module.get_manifest(addon)
manif = odoo.modules.module._get_manifest_cached(addon)
from_terp = IrModule.get_values_from_terp(manif)
from_terp['name'] = addon
from_terp['depends'] = manif.get('depends', ['base'])
@@ -297,7 +297,7 @@ class IrAsset(models.Model):
manifs = sorted(manifs, key=sort_key)
return misc.topological_sort({manif['name']: manif['depends'] for manif in manifs})
return misc.topological_sort({manif['name']: tuple(manif['depends']) for manif in manifs})
@api.model
@tools.ormcache()
@@ -336,7 +336,7 @@ class IrAsset(models.Model):
path_def = fs2web(path_def) # we expect to have all path definition unix style or url style, this is a safety
path_parts = [part for part in path_def.split('/') if part]
addon = path_parts[0]
addon_manifest = odoo.modules.module.get_manifest(addon)
addon_manifest = odoo.modules.module._get_manifest_cached(addon)
safe_path = True
if addon_manifest:
@@ -111,7 +111,7 @@ class AddonManifestPatched(TransactionCase):
}
self.patch(self.env.registry, '_init_modules', self.installed_modules)
self.patch(odoo.modules.module, 'get_manifest', Mock(side_effect=lambda module: self.manifests.get(module, {})))
self.patch(odoo.modules.module, '_get_manifest_cached', Mock(side_effect=lambda module: self.manifests.get(module, {})))
class FileTouchable(AddonManifestPatched):