diff --git a/addons/website/tests/test_views.py b/addons/website/tests/test_views.py index 393001f1b3a..bb7f08d2a2b 100644 --- a/addons/website/tests/test_views.py +++ b/addons/website/tests/test_views.py @@ -2,13 +2,14 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from hashlib import sha256 +import copy import unittest from unittest.mock import patch from itertools import zip_longest from lxml import etree as ET, html from lxml.html import builder as h -from odoo.modules.module import _DEFAULT_MANIFEST, get_manifest +from odoo.modules.module import _DEFAULT_MANIFEST from odoo.tests import common, HttpCase, tagged @@ -1510,10 +1511,9 @@ class TestThemeViews(common.TransactionCase): main_view.with_context(website_id=website_1.id).arch = 'specific' # 2. Simulate a theme install with a child view of `main_view` + patcher = patch('odoo.modules.module._get_manifest_cached', return_value=copy.deepcopy(_DEFAULT_MANIFEST)) + self.startPatcher(patcher) test_theme_module = self.env['ir.module.module'].create({'name': 'test_theme'}) - # Themes are required to have a valid manifest, including a `new_page_templates` property. - # This theme is created in python and therefore has no manifest. - get_manifest('test_theme').update(_DEFAULT_MANIFEST) self.env['ir.model.data'].create({ 'module': 'base', 'name': 'module_test_theme_module', diff --git a/odoo/addons/base/tests/test_module.py b/odoo/addons/base/tests/test_module.py index 1d2009db54c..b37c72e9485 100644 --- a/odoo/addons/base/tests/test_module.py +++ b/odoo/addons/base/tests/test_module.py @@ -7,6 +7,7 @@ from unittest.mock import patch import odoo.addons from odoo.modules.module import load_manifest +from odoo.modules.module import get_manifest from odoo.release import major_version from odoo.tests.common import BaseCase @@ -71,6 +72,14 @@ class TestModuleManifest(BaseCase): 'website': '', }) + def test_change_manifest(self): + module_name = 'base' + new_manifest = get_manifest(module_name) + orig_auto_install = new_manifest['auto_install'] + new_manifest['auto_install'] = not orig_auto_install + self.assertNotEqual(new_manifest, get_manifest(module_name)) + self.assertEqual(orig_auto_install, get_manifest(module_name)['auto_install']) + def test_missing_manifest(self): with self.assertLogs('odoo.modules.module', 'DEBUG') as capture: manifest = load_manifest(self.module_name) diff --git a/odoo/modules/module.py b/odoo/modules/module.py index a12fd5e9a41..c93a630c0d4 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -312,6 +312,7 @@ def load_manifest(module, mod_path=None): return {} manifest = copy.deepcopy(_DEFAULT_MANIFEST) + manifest['icon'] = get_module_icon(module) with tools.file_open(manifest_file, mode='r') as f: @@ -352,7 +353,6 @@ def load_manifest(module, mod_path=None): return manifest -@functools.lru_cache(maxsize=None) def get_manifest(module, mod_path=None): """ Get the module manifest. @@ -365,6 +365,10 @@ def get_manifest(module, mod_path=None): when the manifest was not found. :rtype: dict """ + return copy.deepcopy(_get_manifest_cached(module, mod_path)) + +@functools.lru_cache(maxsize=None) +def _get_manifest_cached(module, mod_path=None): return load_manifest(module, mod_path) def load_information_from_description_file(module, mod_path=None):