diff --git a/apps_download/README.rst b/apps_download/README.rst index ac7ba075..e23e4f18 100644 --- a/apps_download/README.rst +++ b/apps_download/README.rst @@ -73,6 +73,11 @@ Contributors * Alexandre D. Díaz * Ernesto Tejeda +* `PyTech `_: + + * Simone Rubino + * Alessandro Uffreduzzi + Maintainers ~~~~~~~~~~~ diff --git a/apps_download/models/product_product.py b/apps_download/models/product_product.py index 15a84c3d..3b46aa09 100644 --- a/apps_download/models/product_product.py +++ b/apps_download/models/product_product.py @@ -97,7 +97,7 @@ def generate_zip_file(self): tmp_zip_file = "%s.zip" % tmp_zip_file with open(tmp_zip_file, "rb") as file_obj: try: - data_encode = base64.encodestring(file_obj.read()) + data_encode = base64.encodebytes(file_obj.read()) self.env["ir.attachment"].create( { "datas": data_encode, diff --git a/apps_download/readme/CONTRIBUTORS.rst b/apps_download/readme/CONTRIBUTORS.rst index b98c2322..45f17fb5 100644 --- a/apps_download/readme/CONTRIBUTORS.rst +++ b/apps_download/readme/CONTRIBUTORS.rst @@ -6,3 +6,8 @@ * Víctor M.M. Torres * Alexandre D. Díaz * Ernesto Tejeda + +* `PyTech `_: + + * Simone Rubino + * Alessandro Uffreduzzi diff --git a/apps_download/static/description/index.html b/apps_download/static/description/index.html index 3bd93aef..a8a6e226 100644 --- a/apps_download/static/description/index.html +++ b/apps_download/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -421,12 +421,19 @@

Contributors

  • Ernesto Tejeda
  • +
  • PyTech: +
  • Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    diff --git a/apps_download/tests/test_app_download.py b/apps_download/tests/test_app_download.py index d4490ba6..c7a4ca3f 100644 --- a/apps_download/tests/test_app_download.py +++ b/apps_download/tests/test_app_download.py @@ -5,10 +5,11 @@ import os from odoo.exceptions import ValidationError -from odoo.tests.common import TransactionCase +from odoo.addons.apps_product_creator.tests.common import Common -class TestAppDownload(TransactionCase): + +class TestAppDownload(Common): """Test for the Add download""" def setUp(self): @@ -26,13 +27,15 @@ def setUp(self): "module_path": module_path, } ) - module_path = os.path.join(test_path, "test_modules", "test_module") + module_name = "test_module" + self.odoo_module1_version2.technical_name = module_name self.main_app_product = self.env["product.product"].create( { "name": "business_requirement_deliverable_project", - "module_path": module_path, + "odoo_module_version_id": self.odoo_module1_version2.id, } ) + self.main_app_product.module_path = os.path.join(test_path, "test_modules") def test_dependency(self): self.main_app_product.write( @@ -48,3 +51,23 @@ def test_dependency(self): self.main_app_product.write( {"dependent_product_ids": [(6, 0, self.main_app_product.ids)]} ) + + def _get_attachments(self, products): + return self.env["ir.attachment"].search( + [("res_id", "=", products.ids), ("res_model", "=", products._name)], + ) + + def test_generate_zip(self): + """The attachment of a product can be generated.""" + # Arrange + product = self.main_app_product + existing_attachments = self._get_attachments(product) + # pre-condition + self.assertTrue(self.main_app_product.module_path) + + # Act + product.generate_zip_file() + + # Assert + zip_file = self._get_attachments(product) - existing_attachments + self.assertTrue(zip_file) diff --git a/apps_product_creator/tests/common.py b/apps_product_creator/tests/common.py new file mode 100644 index 00000000..efe24ae3 --- /dev/null +++ b/apps_product_creator/tests/common.py @@ -0,0 +1,81 @@ +# Copyright (C) 2017-Today: Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import SavepointCase +from odoo.tools import config + + +class Common(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + # Trick this configuration value for avoiding an error + config["source_code_local_path"] = "/tmp/" + cls.organization1 = cls.env["github.organization"].create( + {"name": "Organization 1", "github_name": "login"} + ) + + cls.organization_serie1 = cls.env["github.organization.serie"].create( + {"name": "12.0", "sequence": 1, "organization_id": cls.organization1.id} + ) + + cls.repository1 = cls.env["github.repository"].create( + {"name": "Repository1", "organization_id": cls.organization1.id} + ) + + cls.branch1 = cls.env["github.repository.branch"].create( + { + "name": "12.0", + "repository_id": cls.repository1.id, + "organization_id": cls.organization1.id, + } + ) + + cls.odoo_module2 = cls.env["odoo.module"].create( + {"technical_name": "odoo_module2"} + ) + + cls.odoo_module1_version2 = cls.env["odoo.module.version"].create( + { + "name": "Odoo Module 2", + "technical_name": "odoo_module2", + "module_id": cls.odoo_module2.id, + "repository_branch_id": cls.branch1.id, + "license": "AGPL-3", + "summary": "Summary Test", + "website": "Website Test", + "description_rst": "Description Test", + "version": "10.0", + "author": "OCA", + "depends": "base", + "external_dependencies": "{}", + "full_module_path": "/repo/10.0/odoo_module_2", + } + ) + + cls.odoo_module1 = cls.env["odoo.module"].create( + { + "technical_name": "odoo_module1", + "dependence_module_version_ids": [ + (6, 0, [cls.odoo_module1_version2.id]) + ], + } + ) + + cls.odoo_module1_version1 = cls.env["odoo.module.version"].create( + { + "name": "Odoo Module 1", + "technical_name": "odoo_module1", + "module_id": cls.odoo_module1.id, + "repository_branch_id": cls.branch1.id, + "license": "AGPL-3", + "summary": "Summary Test", + "website": "Website Test", + "description_rst": "Description Test", + "version": "10.0", + "author": "OCA", + "depends": "base", + "external_dependencies": "{}", + "full_module_path": "/repo/10.0/odoo_module_1", + } + ) + cls.odoo_module2.action_create_product() diff --git a/apps_product_creator/tests/test_apps_product_creator.py b/apps_product_creator/tests/test_apps_product_creator.py index e24fb20a..4e86ca22 100644 --- a/apps_product_creator/tests/test_apps_product_creator.py +++ b/apps_product_creator/tests/test_apps_product_creator.py @@ -1,85 +1,10 @@ # Copyright (C) 2017-Today: Odoo Community Association (OCA) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo.tests.common import SavepointCase -from odoo.tools import config +from .common import Common -class TestAppsProductCreator(SavepointCase): - @classmethod - def setUpClass(cls): - super().setUpClass() - # Trick this configuration value for avoiding an error - config["source_code_local_path"] = "/tmp/" - cls.organization1 = cls.env["github.organization"].create( - {"name": "Organization 1", "github_name": "login"} - ) - - cls.organization_serie1 = cls.env["github.organization.serie"].create( - {"name": "12.0", "sequence": 1, "organization_id": cls.organization1.id} - ) - - cls.repository1 = cls.env["github.repository"].create( - {"name": "Repository1", "organization_id": cls.organization1.id} - ) - - cls.branch1 = cls.env["github.repository.branch"].create( - { - "name": "12.0", - "repository_id": cls.repository1.id, - "organization_id": cls.organization1.id, - } - ) - - cls.odoo_module2 = cls.env["odoo.module"].create( - {"technical_name": "odoo_module2"} - ) - - cls.odoo_module1_version2 = cls.env["odoo.module.version"].create( - { - "name": "Odoo Module 2", - "technical_name": "odoo_module2", - "module_id": cls.odoo_module2.id, - "repository_branch_id": cls.branch1.id, - "license": "AGPL-3", - "summary": "Summary Test", - "website": "Website Test", - "description_rst": "Description Test", - "version": "10.0", - "author": "OCA", - "depends": "base", - "external_dependencies": "{}", - "full_module_path": "/repo/10.0/odoo_module_2", - } - ) - - cls.odoo_module1 = cls.env["odoo.module"].create( - { - "technical_name": "odoo_module1", - "dependence_module_version_ids": [ - (6, 0, [cls.odoo_module1_version2.id]) - ], - } - ) - - cls.odoo_module1_version1 = cls.env["odoo.module.version"].create( - { - "name": "Odoo Module 1", - "technical_name": "odoo_module1", - "module_id": cls.odoo_module1.id, - "repository_branch_id": cls.branch1.id, - "license": "AGPL-3", - "summary": "Summary Test", - "website": "Website Test", - "description_rst": "Description Test", - "version": "10.0", - "author": "OCA", - "depends": "base", - "external_dependencies": "{}", - "full_module_path": "/repo/10.0/odoo_module_1", - } - ) - cls.odoo_module2.action_create_product() +class TestAppsProductCreator(Common): def test1_product_create(self): self.assertFalse(self.odoo_module1.product_template_id) self.odoo_module1.action_create_product()