[FIX] base_import_module: add function returning dependencies
A function that returns the list of missing modules is needed to know if the the customer needs to changi his plan when importing an industry module. closes odoo/odoo#144241 Signed-off-by: Pierre Masereel (pim) <pim@odoo.com>
This commit is contained in:
@@ -29,6 +29,10 @@ class BaseImportModule(models.TransientModel):
|
||||
'url': '/web',
|
||||
}
|
||||
|
||||
def get_dependencies_to_install_names(self):
|
||||
module_ids = self.env['ir.module.module']._get_missing_dependencies_modules(base64.decodebytes(self.module_file))
|
||||
return module_ids.mapped('name')
|
||||
|
||||
def action_module_open(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
|
||||
@@ -337,3 +337,19 @@ class TestImportModuleHttp(TestImportModule, odoo.tests.HttpCase):
|
||||
self.assertEqual(asset.path, asset_path)
|
||||
asset_data = files[1][1]
|
||||
self.assertEqual(self.url_open(asset_path).content, asset_data)
|
||||
|
||||
def test_check_zip_dependencies(self):
|
||||
files = [
|
||||
('foo/__manifest__.py', b"{'data': ['data.xml']}")
|
||||
]
|
||||
archive = BytesIO()
|
||||
with ZipFile(archive, 'w') as zipf:
|
||||
for path, data in files:
|
||||
zipf.writestr(path, data)
|
||||
import_module = self.env['base.import.module'].create({
|
||||
'module_file': base64.b64encode(archive.getvalue()),
|
||||
'state': 'init',
|
||||
'modules_dependencies': self.env['ir.module.module']._get_missing_dependencies(archive.getvalue())
|
||||
})
|
||||
dependencies_names = import_module.get_dependencies_to_install_names()
|
||||
self.assertEqual(dependencies_names, [])
|
||||
|
||||
Reference in New Issue
Block a user