-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathir_module_module_extract_installed.py
60 lines (53 loc) · 2.07 KB
/
ir_module_module_extract_installed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Server action to output all modules to be included on the manifest, useful
# when initializing a module for an app of an already-existing instance,
# or when removing superfluous dependencies
MODNAMES_TO_ADD = []
# Add here app's module name if already installed, so its dependencies are not considered
MODNAMES_TO_IGNORE = [
# All modules depend on base anyway
"base",
# Don't install it unless necessary, to avoid performance issues
# If there's no data for it, then it doesn't make sense to have it in CI
"base_automation",
# Dependency of OdooStudio, not useful in CI
"base_import_module",
# Not useful and deprecated in newer versions anyway
"odoo_referral",
"web_dashboard",
# In case this is run in a test instance on DeployV
"web_environment_ribbon_isolated",
# Studio is not useful in CI
"web_studio",
"studio_customization",
]
def compute_dependencies(modules):
"""Compute recursive dependencies for the provided modules"""
dependencies = modules.mapped('dependencies_id.depend_id')
for x in range(10): # Didn't want to use while True
old_dependencies = dependencies
dependencies |= dependencies.mapped('dependencies_id.depend_id')
if old_dependencies == dependencies:
break
return dependencies
module_obj = env['ir.module.module'].sudo()
installed_modules = module_obj.search([
('state', '=', 'installed'),
'|',
('auto_install', '=', False),
# l10n_mx_edi is marked as autoinstall, but it should be added anyway
('category_id.name', '=', 'EDI'),
('name', 'not in', MODNAMES_TO_IGNORE),
])
# Include only modules that are not already installed by any other module,
# i.e. are not dependencies of any other one
modnames_to_add = []
for module in installed_modules:
other_modules = installed_modules - module
other_dependencies = compute_dependencies(other_modules)
if module not in other_dependencies:
modnames_to_add.append(module.name)
output = "\n".join([
'"%s",' % modname
for modname in sorted(modnames_to_add)
])
raise Warning(output)