Skip to content

Commit

Permalink
Merge pull request #4132 from ForgeFlow/13.0-update-upstream-483cc20b95e
Browse files Browse the repository at this point in the history
[13.0] update upstream 483cc20
  • Loading branch information
pedrobaeza authored Sep 21, 2023
2 parents 26bb0f4 + ffb94bc commit 6117635
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
11 changes: 11 additions & 0 deletions odoo/addons/base/models/ir_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ def get_transforms(self):
('to install', 'To be installed'),
]

XML_DECLARATION = (
'<?xml version='.encode('utf-8'),
'<?xml version='.encode('utf-16-be'),
'<?xml version='.encode('utf-16-le'),
)

class Module(models.Model):
_name = "ir.module.module"
_rec_name = "shortdesc"
Expand Down Expand Up @@ -178,6 +184,11 @@ def _get_desc(self):
if path:
with tools.file_open(path, 'rb') as desc_file:
doc = desc_file.read()
if not doc.startswith(XML_DECLARATION):
try:
doc = doc.decode('utf-8')
except UnicodeDecodeError:
pass
html = lxml.html.document_fromstring(doc)
for element, attribute, link, pos in html.iterlinks():
if element.get('src') and not '//' in element.get('src') and not 'static/' in element.get('src'):
Expand Down
45 changes: 24 additions & 21 deletions odoo/modules/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,7 @@ def get_test_modules(module, openupgrade_prefix=None):
feed unittest.TestLoader.loadTestsFromModule() """
# Try to import the module
results = _get_tests_modules('odoo.addons', module, openupgrade_prefix)

try:
importlib.import_module('odoo.upgrade.%s' % module)
except ImportError:
pass
else:
results += list(_get_upgrade_test_modules(module, openupgrade_prefix))
results += list(_get_upgrade_test_modules(module, openupgrade_prefix))

return results

Expand Down Expand Up @@ -509,20 +503,29 @@ def _get_upgrade_test_modules(module, openupgrade_prefix=None):
if openupgrade_prefix is None:
openupgrade_prefix = ''
name = openupgrade_prefix + '.tests'
upg = importlib.import_module("odoo.upgrade")
for path in map(Path, upg.__path__):
if openupgrade_prefix:
tests = (path / module / openupgrade_prefix[1:] / "tests").glob("test_*.py")
else:
tests = (path / module / "tests").glob("test_*.py")
for test in tests:
spec = importlib.util.spec_from_file_location(f"odoo.upgrade.{module}{name}.{test.stem}", test)
if not spec:
continue
pymod = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = pymod
spec.loader.exec_module(pymod)
yield pymod
upgrade_modules = (
f"odoo.upgrade.{module}",
f"odoo.addons.{module}.migrations",
f"odoo.addons.{module}.upgrades",
)
for module_name in upgrade_modules:
try:
upg = importlib.import_module(module_name)
except ImportError:
continue
for path in map(Path, upg.__path__):
if openupgrade_prefix:
tests = path.glob(openupgrade_prefix[1:] + "/tests/test_*.py")
else:
tests = path.glob("tests/test_*.py")
for test in tests:
spec = importlib.util.spec_from_file_location(f"{upg.__name__}{name}.{test.stem}", test)
if not spec:
continue
pymod = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = pymod
spec.loader.exec_module(pymod)
yield pymod


class OdooTestResult(unittest.result.TestResult):
Expand Down

0 comments on commit 6117635

Please sign in to comment.