diff --git a/apps_download/README.rst b/apps_download/README.rst new file mode 100644 index 00000000..92f1ef48 --- /dev/null +++ b/apps_download/README.rst @@ -0,0 +1,97 @@ +============================= +Product Download for Appstore +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bea891ad316a44b7704e516e6af183776da794d7817065b8aa37f4270203deb2 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fapps--store-lightgray.png?logo=github + :target: https://github.com/OCA/apps-store/tree/18.0/apps_download + :alt: OCA/apps-store +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/apps-store-18-0/apps-store-18-0-apps_download + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/apps-store&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Providing facility for the maintain dependency of Module at level of +product and creating Zip file with all dependent modules. + +**Table of contents** + +.. contents:: + :local: + +Known issues / Roadmap +====================== + +- Creation of an error queue if the exception occurs while generating + zip file of the product + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* BizzAppDev +* AgentERP +* Elico Corp + +Contributors +------------ + +- Ruchir Shukla +- Georg Nottere +- Eric Caudal +- `Tecnativa `__: + + - Víctor M.M. Torres + - Alexandre D. Díaz + - Ernesto Tejeda + +- `PyTech `__: + + - Simone Rubino + - Alessandro Uffreduzzi + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/apps-store `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/apps_download/__init__.py b/apps_download/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/apps_download/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/apps_download/__manifest__.py b/apps_download/__manifest__.py new file mode 100644 index 00000000..edbd2544 --- /dev/null +++ b/apps_download/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2017-2019 BizzAppDev +# Copyright 2017-2019 AgentERP +# Copyright 2017-2019 Elico Corp +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Product Download for Appstore", + "version": "18.0.1.0.0", + "author": "BizzAppDev, AgentERP, Elico Corp, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/apps-store", + "license": "AGPL-3", + "category": "Sales", + "depends": [ + "base", + "github_connector_odoo", + "apps_product_creator", + ], + "summary": "Product Download for Appstore", + "data": ["views/product_template_view.xml", "data/cron_scheduler.xml"], + "installable": True, + "auto_install": False, + "application": False, +} diff --git a/apps_download/data/cron_scheduler.xml b/apps_download/data/cron_scheduler.xml new file mode 100644 index 00000000..f6481f6e --- /dev/null +++ b/apps_download/data/cron_scheduler.xml @@ -0,0 +1,19 @@ + + + + + Generate ZIP files for all products + + code + model.generate_zip_file_batch() + 1 + days + + 2025-10-31 12:00:00 + + + diff --git a/apps_download/i18n/apps_download.pot b/apps_download/i18n/apps_download.pot new file mode 100644 index 00000000..6727d89c --- /dev/null +++ b/apps_download/i18n/apps_download.pot @@ -0,0 +1,75 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * apps_download +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__display_name +msgid "Display Name" +msgstr "" + +#. module: apps_download +#: code:addons/apps_download/models/product_product.py:0 +#, python-format +msgid "Error: You cannot create recursive dependency." +msgstr "" + +#. module: apps_download +#: model:ir.actions.server,name:apps_download.ir_cron_scheduler_generate_zip_ir_actions_server +#: model:ir.cron,cron_name:apps_download.ir_cron_scheduler_generate_zip +#: model:ir.cron,name:apps_download.ir_cron_scheduler_generate_zip +msgid "Generate ZIP files for all products" +msgstr "" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Get all Dependencies" +msgstr "" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__id +msgid "ID" +msgstr "" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product____last_update +msgid "Last Modified on" +msgstr "" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__module_path +msgid "Local Path" +msgstr "" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Module Dependencies" +msgstr "" + +#. module: apps_download +#: code:addons/apps_download/models/product_product.py:0 +#, python-format +msgid "" +"Module code not downloaded yet. Please initialize the code in the associated" +" Github Repository Branch by downloading the source code." +msgstr "" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Modules Dependencies" +msgstr "" + +#. module: apps_download +#: model:ir.model,name:apps_download.model_product_product +msgid "Product" +msgstr "" diff --git a/apps_download/i18n/es.po b/apps_download/i18n/es.po new file mode 100644 index 00000000..252c1ab5 --- /dev/null +++ b/apps_download/i18n/es.po @@ -0,0 +1,83 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * apps_download +# +# Translators: +# enjolras , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-10 01:37+0000\n" +"PO-Revision-Date: 2024-01-26 16:33+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: apps_download +#: code:addons/apps_download/models/product_product.py:0 +#, python-format +msgid "Error: You cannot create recursive dependency." +msgstr "Error: No se puede crear una dependencia recursiva." + +#. module: apps_download +#: model:ir.actions.server,name:apps_download.ir_cron_scheduler_generate_zip_ir_actions_server +#: model:ir.cron,cron_name:apps_download.ir_cron_scheduler_generate_zip +#: model:ir.cron,name:apps_download.ir_cron_scheduler_generate_zip +msgid "Generate ZIP files for all products" +msgstr "Generar archivos ZIP para todos los productos" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Get all Dependencies" +msgstr "Obtener todas las Dependencias" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__id +msgid "ID" +msgstr "ID" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product____last_update +msgid "Last Modified on" +msgstr "Última Modificación el" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__module_path +msgid "Local Path" +msgstr "Ruta local" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Module Dependencies" +msgstr "Dependencia del Módulo" + +#. module: apps_download +#: code:addons/apps_download/models/product_product.py:0 +#, python-format +msgid "" +"Module code not downloaded yet. Please initialize the code in the associated " +"Github Repository Branch by downloading the source code." +msgstr "" +"El código del módulo aún no se ha descargado. Por favor, inicialice el " +"código en la Rama Repositorio Github asociada descargando el código fuente." + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Modules Dependencies" +msgstr "Módulos Dependencias" + +#. module: apps_download +#: model:ir.model,name:apps_download.model_product_product +msgid "Product" +msgstr "Producto" diff --git a/apps_download/i18n/fr.po b/apps_download/i18n/fr.po new file mode 100644 index 00000000..197856eb --- /dev/null +++ b/apps_download/i18n/fr.po @@ -0,0 +1,83 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * apps_download +# +# Translators: +# Quentin THEURET , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-08 01:39+0000\n" +"PO-Revision-Date: 2018-02-08 01:39+0000\n" +"Last-Translator: Quentin THEURET , 2018\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__display_name +msgid "Display Name" +msgstr "" + +#. module: apps_download +#: code:addons/apps_download/models/product_product.py:0 +#, python-format +msgid "Error: You cannot create recursive dependency." +msgstr "Erreur : Vous ne pouvez pas créer de dépendance récursive." + +#. module: apps_download +#: model:ir.actions.server,name:apps_download.ir_cron_scheduler_generate_zip_ir_actions_server +#: model:ir.cron,cron_name:apps_download.ir_cron_scheduler_generate_zip +#: model:ir.cron,name:apps_download.ir_cron_scheduler_generate_zip +msgid "Generate ZIP files for all products" +msgstr "" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +#, fuzzy +msgid "Get all Dependencies" +msgstr "Récupérer tous les dépendances" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__id +msgid "ID" +msgstr "" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product____last_update +msgid "Last Modified on" +msgstr "" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__module_path +msgid "Local Path" +msgstr "" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +#, fuzzy +msgid "Module Dependencies" +msgstr "Dépendances du module" + +#. module: apps_download +#: code:addons/apps_download/models/product_product.py:0 +#, python-format +msgid "" +"Module code not downloaded yet. Please initialize the code in the associated " +"Github Repository Branch by downloading the source code." +msgstr "" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +#, fuzzy +msgid "Modules Dependencies" +msgstr "Dépendances des modules" + +#. module: apps_download +#: model:ir.model,name:apps_download.model_product_product +msgid "Product" +msgstr "Produit" diff --git a/apps_download/i18n/it.po b/apps_download/i18n/it.po new file mode 100644 index 00000000..bbec1bc0 --- /dev/null +++ b/apps_download/i18n/it.po @@ -0,0 +1,80 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * apps_download +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-01-20 11:06+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.6.2\n" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: apps_download +#: code:addons/apps_download/models/product_product.py:0 +#, python-format +msgid "Error: You cannot create recursive dependency." +msgstr "Errore: impossibile creare dipendenze ricorsive." + +#. module: apps_download +#: model:ir.actions.server,name:apps_download.ir_cron_scheduler_generate_zip_ir_actions_server +#: model:ir.cron,cron_name:apps_download.ir_cron_scheduler_generate_zip +#: model:ir.cron,name:apps_download.ir_cron_scheduler_generate_zip +msgid "Generate ZIP files for all products" +msgstr "Genera file ZIP per tutti i prodotti" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Get all Dependencies" +msgstr "Ottieni tutte le dipendenze" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__id +msgid "ID" +msgstr "ID" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__module_path +msgid "Local Path" +msgstr "Percorso locale" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Module Dependencies" +msgstr "Dipendenze modulo" + +#. module: apps_download +#: code:addons/apps_download/models/product_product.py:0 +#, python-format +msgid "" +"Module code not downloaded yet. Please initialize the code in the associated " +"Github Repository Branch by downloading the source code." +msgstr "" +"Il codice del modulo non è ancora stato scaricato. Inizializza il codice nel " +"branch del repository Github associato scaricando il codice sorgente." + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Modules Dependencies" +msgstr "Dipendenze moduli" + +#. module: apps_download +#: model:ir.model,name:apps_download.model_product_product +msgid "Product" +msgstr "Prodotto" diff --git a/apps_download/i18n/pt_BR.po b/apps_download/i18n/pt_BR.po new file mode 100644 index 00000000..f643ef2a --- /dev/null +++ b/apps_download/i18n/pt_BR.po @@ -0,0 +1,88 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * apps_download +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-11-24 18:09+0000\n" +"Last-Translator: Rodrigo Macedo \n" +"Language-Team: none\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.8\n" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__display_name +msgid "Display Name" +msgstr "" + +#. module: apps_download +#: code:addons/apps_download/models/product_product.py:0 +#, python-format +msgid "Error: You cannot create recursive dependency." +msgstr "Erro: você não pode criar dependência recursiva." + +#. module: apps_download +#: model:ir.actions.server,name:apps_download.ir_cron_scheduler_generate_zip_ir_actions_server +#: model:ir.cron,cron_name:apps_download.ir_cron_scheduler_generate_zip +#: model:ir.cron,name:apps_download.ir_cron_scheduler_generate_zip +msgid "Generate ZIP files for all products" +msgstr "Gere arquivos ZIP para todos os produtos" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Get all Dependencies" +msgstr "Obter todas as dependências" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__id +msgid "ID" +msgstr "" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product____last_update +msgid "Last Modified on" +msgstr "" + +#. module: apps_download +#: model:ir.model.fields,field_description:apps_download.field_product_product__module_path +msgid "Local Path" +msgstr "Caminho Local" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Module Dependencies" +msgstr "Dependências dos módulos" + +#. module: apps_download +#: code:addons/apps_download/models/product_product.py:0 +#, python-format +msgid "" +"Module code not downloaded yet. Please initialize the code in the associated " +"Github Repository Branch by downloading the source code." +msgstr "" + +#. module: apps_download +#: model_terms:ir.ui.view,arch_db:apps_download.view_product_product_view_dependent_form +msgid "Modules Dependencies" +msgstr "Dependências dos módulos" + +#. module: apps_download +#: model:ir.model,name:apps_download.model_product_product +msgid "Product" +msgstr "Produto" + +#~ msgid "Category1" +#~ msgstr "Categoria1" + +#~ msgid "Odoo Module 1" +#~ msgstr "Módulo Odoo 1" + +#, fuzzy +#~ msgid "Units" +#~ msgstr "Unidade(s)" diff --git a/apps_download/models/__init__.py b/apps_download/models/__init__.py new file mode 100644 index 00000000..5c74c8c3 --- /dev/null +++ b/apps_download/models/__init__.py @@ -0,0 +1 @@ +from . import product_product diff --git a/apps_download/models/product_product.py b/apps_download/models/product_product.py new file mode 100644 index 00000000..792b4ed3 --- /dev/null +++ b/apps_download/models/product_product.py @@ -0,0 +1,138 @@ +# Copyright (C) 2017-Today: Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +import base64 +import logging +import os +import shutil +import tempfile +import time + +from odoo import _, api, fields, models +from odoo.exceptions import UserError, ValidationError + +_logger = logging.getLogger(__name__) + + +class ProductProduct(models.Model): + _inherit = "product.product" + + module_path = fields.Char( + related="odoo_module_version_id.repository_branch_id.local_path", readonly=True + ) + + @api.constrains("dependent_product_ids") + def check_dependent_recursion(self): + if self._has_cycle("dependent_product_ids"): + raise ValidationError(_("Error: You cannot create recursive dependency.")) + + @api.model + def child_dependency(self, children): + res = self.env["product.product"] + for child in children: + if not child.dependent_product_ids: + continue + res |= child.dependent_product_ids + res |= self.child_dependency(child.dependent_product_ids) + return res + + def create_dependency_list(self): + ret_val = {} + for product in self: + ret_val[product.id] = product.dependent_product_ids + if product.dependent_product_ids: + ret_val[product.id] |= self.child_dependency( + product.dependent_product_ids + ) + return ret_val + + def _get_module_path(self): + return self.module_path + "/" + self.odoo_module_version_id.technical_name + + def generate_zip_file(self): + for product in self.filtered("module_path"): + tmp_dir = tempfile.mkdtemp() + tmp_dir_2 = tempfile.mkdtemp() + dependent_products = product.create_dependency_list() + dependent_products = dependent_products[product.id] + + for dependent_pro in dependent_products.filtered("module_path"): + tmp_module_path = os.path.join( + tmp_dir, dependent_pro.odoo_module_version_id.technical_name + ) + shutil.copytree( + dependent_pro.module_path + + "/" + + dependent_pro.odoo_module_version_id.technical_name, + tmp_module_path, + ) + + tmp_module_path = os.path.join( + tmp_dir, product.odoo_module_version_id.technical_name + ) + module_path = product._get_module_path() + try: + shutil.copytree(module_path, tmp_module_path) + except FileNotFoundError: + raise UserError( + _( + "Module code not downloaded yet." + " Please initialize the code in the associated" + " Github Repository Branch by downloading the source code." + ) + ) from None + time_version_value = time.strftime("_%y%m%d_%H%M%S") + attr_values = product.product_template_attribute_value_ids + if attr_values: + time_version_value = "_{}{}".format( + "_".join( + [name.replace(".", "_") for name in attr_values.mapped("name")] + ), + time_version_value, + ) + + tmp_zip_file = os.path.join(tmp_dir_2, product.name) + time_version_value + shutil.make_archive(tmp_zip_file, "zip", tmp_dir) + tmp_zip_file = f"{tmp_zip_file}.zip" + with open(tmp_zip_file, "rb") as file_obj: + try: + data_encode = base64.encodebytes(file_obj.read()) + self.env["ir.attachment"].create( + { + "datas": data_encode, + "store_fname": ( + product.name.replace(" ", "-") + + time_version_value + + ".zip" + ), + "type": "binary", + "name": product.name + time_version_value + ".zip", + "res_model": product._name, + "res_id": product.id, + # TODO: check if obsolete field - most probable scenario + # "product_downloadable": True, + } + ) + except Exception as exc: + _logger.error( + "Error creating attachment %s Error is: %s", + tmp_zip_file, + str(exc), + ) + try: + shutil.rmtree(tmp_dir) + except OSError as exc: + _logger.warning( + f"Could not remove Tempdir {tmp_dir}, Errormsg {str(exc)}" + ) + try: + shutil.rmtree(tmp_dir_2) + except OSError as exc: + _logger.warning( + f"Could not remove Tempdir 2 {tmp_dir}, Errormsg {str(exc)}" + ) + + @api.model + def generate_zip_file_batch(self): + self.search([]).generate_zip_file() diff --git a/apps_download/pyproject.toml b/apps_download/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/apps_download/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/apps_download/readme/CONTRIBUTORS.md b/apps_download/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..3e233514 --- /dev/null +++ b/apps_download/readme/CONTRIBUTORS.md @@ -0,0 +1,10 @@ +- Ruchir Shukla \<\> +- Georg Nottere \<\> +- Eric Caudal \<\> +- [Tecnativa](https://www.tecnativa.com): + - Víctor M.M. Torres + - Alexandre D. Díaz + - Ernesto Tejeda +- [PyTech](https://www.pytech.it): + - Simone Rubino \<\> + - Alessandro Uffreduzzi \<\> diff --git a/apps_download/readme/DESCRIPTION.md b/apps_download/readme/DESCRIPTION.md new file mode 100644 index 00000000..c13fd800 --- /dev/null +++ b/apps_download/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +Providing facility for the maintain dependency of Module at level of +product and creating Zip file with all dependent modules. diff --git a/apps_download/readme/ROADMAP.md b/apps_download/readme/ROADMAP.md new file mode 100644 index 00000000..d8ef716b --- /dev/null +++ b/apps_download/readme/ROADMAP.md @@ -0,0 +1,2 @@ +- Creation of an error queue if the exception occurs while generating + zip file of the product diff --git a/apps_download/static/description/icon.png b/apps_download/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/apps_download/static/description/icon.png differ diff --git a/apps_download/static/description/index.html b/apps_download/static/description/index.html new file mode 100644 index 00000000..daa0bdae --- /dev/null +++ b/apps_download/static/description/index.html @@ -0,0 +1,447 @@ + + + + + +Product Download for Appstore + + + +
+

Product Download for Appstore

+ + +

Beta License: AGPL-3 OCA/apps-store Translate me on Weblate Try me on Runboat

+

Providing facility for the maintain dependency of Module at level of +product and creating Zip file with all dependent modules.

+

Table of contents

+ +
+

Known issues / Roadmap

+
    +
  • Creation of an error queue if the exception occurs while generating +zip file of the product
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • BizzAppDev
  • +
  • AgentERP
  • +
  • Elico Corp
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +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.

+

This module is part of the OCA/apps-store project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/apps_download/tests/__init__.py b/apps_download/tests/__init__.py new file mode 100644 index 00000000..d8d05d7a --- /dev/null +++ b/apps_download/tests/__init__.py @@ -0,0 +1 @@ +from . import test_app_download diff --git a/apps_download/tests/test_app_download.py b/apps_download/tests/test_app_download.py new file mode 100644 index 00000000..4ecfbd62 --- /dev/null +++ b/apps_download/tests/test_app_download.py @@ -0,0 +1,73 @@ +# Copyright (C) 2017-Today: Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import os + +from odoo.exceptions import ValidationError + +from odoo.addons.apps_product_creator.tests.common import Common + + +class TestAppDownload(Common): + """Test for the Add download""" + + def setUp(self): + super().setUp() + test_path = os.path.dirname(os.path.realpath(__file__)) + module_path = os.path.join(test_path, "test_modules", "broken_lint") + self.sub_child_product = self.env["product.product"].create( + {"name": "business_requirement", "module_path": module_path} + ) + module_path = os.path.join(test_path, "test_modules", "second_module") + self.child_product = self.env["product.product"].create( + { + "name": "business_requirement_deliverable", + "dependent_product_ids": [(6, 0, self.sub_child_product.ids)], + "module_path": module_path, + } + ) + 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", + "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( + {"dependent_product_ids": [(6, 0, self.child_product.ids)]} + ) + self.assertEqual( + len(self.main_app_product.dependent_product_ids.ids), + 1, + "Dependency: App Dependency does not set properlly", + ) + self.main_app_product.generate_zip_file() + with self.assertRaises(ValidationError): + 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", "in", 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_download/tests/test_modules/broken_lint/README.rst b/apps_download/tests/test_modules/broken_lint/README.rst new file mode 100644 index 00000000..21738b7c --- /dev/null +++ b/apps_download/tests/test_modules/broken_lint/README.rst @@ -0,0 +1 @@ +File for test diff --git a/apps_download/tests/test_modules/broken_lint/__init__.py b/apps_download/tests/test_modules/broken_lint/__init__.py new file mode 100644 index 00000000..6305ed30 --- /dev/null +++ b/apps_download/tests/test_modules/broken_lint/__init__.py @@ -0,0 +1 @@ +# none diff --git a/apps_download/tests/test_modules/broken_lint/__manifest__.py b/apps_download/tests/test_modules/broken_lint/__manifest__.py new file mode 100644 index 00000000..fe5656f1 --- /dev/null +++ b/apps_download/tests/test_modules/broken_lint/__manifest__.py @@ -0,0 +1,11 @@ +# pylint: disable=manifest-version-format +{ + "name": "Broken module for lint tests", + "license": "AGPL-3", + "author": "Odoo Community Association (OCA)", + "version": "13.0.1.0.0", + "depends": [], + "data": [], + "test": [], + "installable": True, +} diff --git a/apps_download/tests/test_modules/second_module/README.rst b/apps_download/tests/test_modules/second_module/README.rst new file mode 100644 index 00000000..21738b7c --- /dev/null +++ b/apps_download/tests/test_modules/second_module/README.rst @@ -0,0 +1 @@ +File for test diff --git a/apps_download/tests/test_modules/second_module/__init__.py b/apps_download/tests/test_modules/second_module/__init__.py new file mode 100644 index 00000000..6305ed30 --- /dev/null +++ b/apps_download/tests/test_modules/second_module/__init__.py @@ -0,0 +1 @@ +# none diff --git a/apps_download/tests/test_modules/second_module/__manifest__.py b/apps_download/tests/test_modules/second_module/__manifest__.py new file mode 100644 index 00000000..713829da --- /dev/null +++ b/apps_download/tests/test_modules/second_module/__manifest__.py @@ -0,0 +1,8 @@ +# pylint: disable=manifest-version-format +{ + "name": "Second empty module for tests", + "version": "13.0.1.0.0", + "author": "Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["base", "test_module"], +} diff --git a/apps_download/tests/test_modules/test_module/README.rst b/apps_download/tests/test_modules/test_module/README.rst new file mode 100644 index 00000000..d00cd1be --- /dev/null +++ b/apps_download/tests/test_modules/test_module/README.rst @@ -0,0 +1,9 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Test module +=========== + +This module was written to check the test of rst syntax. +This is a rst file without syntax error. + diff --git a/apps_download/tests/test_modules/test_module/__init__.py b/apps_download/tests/test_modules/test_module/__init__.py new file mode 100644 index 00000000..c8c7b553 --- /dev/null +++ b/apps_download/tests/test_modules/test_module/__init__.py @@ -0,0 +1 @@ +from . import dummy_model diff --git a/apps_download/tests/test_modules/test_module/__manifest__.py b/apps_download/tests/test_modules/test_module/__manifest__.py new file mode 100644 index 00000000..c3e2f70c --- /dev/null +++ b/apps_download/tests/test_modules/test_module/__manifest__.py @@ -0,0 +1,9 @@ +# pylint: disable=manifest-version-format +{ + "name": "Empty module for tests", + "license": "AGPL-3", + "author": "Odoo Community Association (OCA)", + "version": "13.0.1.0.0", + "depends": ["base", "dependency_module"], # test dependency repo installation + "data": ["security/ir.model.access.csv"], +} diff --git a/apps_download/tests/test_modules/test_module/doc/index.rst b/apps_download/tests/test_modules/test_module/doc/index.rst new file mode 100644 index 00000000..23582458 --- /dev/null +++ b/apps_download/tests/test_modules/test_module/doc/index.rst @@ -0,0 +1,8 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Test module +=========== + +This module was written to check the test of rst syntax. +This is a rst file without syntax error. diff --git a/apps_download/tests/test_modules/test_module/dummy_model.py b/apps_download/tests/test_modules/test_module/dummy_model.py new file mode 100644 index 00000000..c1a2ac87 --- /dev/null +++ b/apps_download/tests/test_modules/test_module/dummy_model.py @@ -0,0 +1,17 @@ +import sys + +from openerp import fields +from openerp.osv import orm + + +class DummyModel(orm.Model): + _name = "dummy.model" + name = fields.Char("Dummy", size=100) + + +# printout non-ASCII text to check unicode issues +# (from Monty Python's "Italian Lesson"...) +sys.stdout.write( + "Eeeeeee! Milano è tanto meglio di Napoli. " + "Milano è la citta la più bella di tutti ... nel mondo...\n" +) diff --git a/apps_download/tests/test_modules/test_module/security/ir.model.access.csv b/apps_download/tests/test_modules/test_module/security/ir.model.access.csv new file mode 100644 index 00000000..63685ca6 --- /dev/null +++ b/apps_download/tests/test_modules/test_module/security/ir.model.access.csv @@ -0,0 +1,2 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_dummy_model","access_dummy_model","model_dummy_model","base.group_user",1,1,1,1 diff --git a/apps_download/tests/test_modules/test_module/static/description/icon.png b/apps_download/tests/test_modules/test_module/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/apps_download/tests/test_modules/test_module/static/description/icon.png differ diff --git a/apps_download/views/product_template_view.xml b/apps_download/views/product_template_view.xml new file mode 100644 index 00000000..2023446f --- /dev/null +++ b/apps_download/views/product_template_view.xml @@ -0,0 +1,29 @@ + + + + + product.product.form + product.product + form + + + + + + +