Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps_download/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Contributors
* Alexandre D. Díaz
* Ernesto Tejeda

* `PyTech <https://www.pytech.it>`_:

* Simone Rubino <simone.rubino@pytech.it>
* Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it>

Maintainers
~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion apps_download/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions apps_download/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@
* Víctor M.M. Torres
* Alexandre D. Díaz
* Ernesto Tejeda

* `PyTech <https://www.pytech.it>`_:

* Simone Rubino <simone.rubino@pytech.it>
* Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it>
17 changes: 12 additions & 5 deletions apps_download/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -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.
Expand Down Expand Up @@ -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 }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -421,12 +421,19 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Ernesto Tejeda</li>
</ul>
</li>
<li><a class="reference external" href="https://www.pytech.it">PyTech</a>:<ul>
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;pytech.it">simone.rubino&#64;pytech.it</a>&gt;</li>
<li>Alessandro Uffreduzzi &lt;<a class="reference external" href="mailto:alessandro.uffreduzzi&#64;pytech.it">alessandro.uffreduzzi&#64;pytech.it</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
31 changes: 27 additions & 4 deletions apps_download/tests/test_app_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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(
Expand All @@ -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)
81 changes: 81 additions & 0 deletions apps_product_creator/tests/common.py
Original file line number Diff line number Diff line change
@@ -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()
79 changes: 2 additions & 77 deletions apps_product_creator/tests/test_apps_product_creator.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down