[FIX] base: avoid no autoinstall propagation

A custom script is modifying the output of
load_information_from_description_file to disable the
auto-install of modules during local testing. It was naively adapted for
v16.0 by replacing the corresponding methods. Since a lru cache was added
(nice optimization in most cases) this is an issue because running lint
test afterward will get the cached value with an incorrect autoinstall
value. It makes sens to avoid reading the file on the filesystem each
time, but making a deepcopy looks like an acceptable safeguard to avoid
hard to debug behaviors.

closes odoo/odoo#143628

X-original-commit: ad10ff4410ccf7c38f6154480484495bb57c53ff
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
Xavier-Do
2023-11-28 06:19:55 +00:00
parent fbfbd1b3f6
commit ad993e673d
3 changed files with 18 additions and 5 deletions
+4 -4
View File
@@ -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 = '<body>specific</body>'
# 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',
+9
View File
@@ -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)
+5 -1
View File
@@ -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):