From bc9b60de4e9c841ff330e61ae81c7033e6e20bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 18 Dec 2024 13:01:17 +0100 Subject: [PATCH] [MIG] attachment_zipped_download: Migration to 17.0 TT52268 --- attachment_zipped_download/__manifest__.py | 2 +- attachment_zipped_download/i18n/es.po | 9 ---- attachment_zipped_download/i18n/fr.po | 6 --- attachment_zipped_download/i18n/it.po | 9 ---- .../tests/test_attachment_zipped_download.py | 51 +++++++------------ .../test_ir_attachment_action_download.py | 13 ++--- 6 files changed, 22 insertions(+), 68 deletions(-) diff --git a/attachment_zipped_download/__manifest__.py b/attachment_zipped_download/__manifest__.py index 3bb3c99ba78..897179747be 100644 --- a/attachment_zipped_download/__manifest__.py +++ b/attachment_zipped_download/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Attachment Zipped Download", - "version": "16.0.2.0.2", + "version": "17.0.1.0.0", "category": "Tools", "website": "https://github.com/OCA/knowledge", "author": "Tecnativa, Odoo Community Association (OCA)", diff --git a/attachment_zipped_download/i18n/es.po b/attachment_zipped_download/i18n/es.po index b9c67e632bf..0ca6983c4d5 100644 --- a/attachment_zipped_download/i18n/es.po +++ b/attachment_zipped_download/i18n/es.po @@ -68,12 +68,3 @@ msgstr "No se encontró ningún documento para descargar." #, python-format msgid "attachments.zip" msgstr "adjuntos.zip" - -#~ msgid "Display Name" -#~ msgstr "Nombre mostrado" - -#~ msgid "ID" -#~ msgstr "ID" - -#~ msgid "Last Modified on" -#~ msgstr "Última modificación el" diff --git a/attachment_zipped_download/i18n/fr.po b/attachment_zipped_download/i18n/fr.po index 3dbf6c8078d..5ad4961a971 100644 --- a/attachment_zipped_download/i18n/fr.po +++ b/attachment_zipped_download/i18n/fr.po @@ -63,9 +63,3 @@ msgstr "Aucune pièce jointe téléchargeable trouvé." #, python-format msgid "attachments.zip" msgstr "pieces-jointes.zip" - -#~ msgid "Display Name" -#~ msgstr "Nom affiché" - -#~ msgid "Last Modified on" -#~ msgstr "Dernière modification le" diff --git a/attachment_zipped_download/i18n/it.po b/attachment_zipped_download/i18n/it.po index 90a57a77ca3..eb6f8a77de4 100644 --- a/attachment_zipped_download/i18n/it.po +++ b/attachment_zipped_download/i18n/it.po @@ -64,12 +64,3 @@ msgstr "Non sono stati trovati documenti da scaricare." #, python-format msgid "attachments.zip" msgstr "attachments.zip" - -#~ msgid "Display Name" -#~ msgstr "Nome visualizzato" - -#~ msgid "ID" -#~ msgstr "ID" - -#~ msgid "Last Modified on" -#~ msgstr "Ultima modifica il" diff --git a/attachment_zipped_download/tests/test_attachment_zipped_download.py b/attachment_zipped_download/tests/test_attachment_zipped_download.py index 1422905eee3..802f1a432ce 100644 --- a/attachment_zipped_download/tests/test_attachment_zipped_download.py +++ b/attachment_zipped_download/tests/test_attachment_zipped_download.py @@ -1,17 +1,18 @@ -# Copyright 2022-2023 Tecnativa - Víctor Martínez +# Copyright 2022-2024 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). import base64 -from unittest import TestCase from odoo.exceptions import AccessError -from odoo.tests import HttpCase, SavepointCase, new_test_user +from odoo.tests import HttpCase, new_test_user +from odoo.addons.base.tests.common import BaseCommon -class TestAttachmentZippedDownloadBase(TestCase): + +class TestAttachmentZippedDownloadBase(BaseCommon): @classmethod - def _create_attachment(cls, env, user, name, model=False, res_id=False): + def _create_attachment(cls, user, name, model=False, res_id=False): return ( - env["ir.attachment"] + cls.env["ir.attachment"] .with_user(user) .create( { @@ -25,22 +26,13 @@ def _create_attachment(cls, env, user, name, model=False, res_id=False): class TestAttachmentZippedDownload(HttpCase, TestAttachmentZippedDownloadBase): - def setUp(self): - super().setUp() - ctx = { - "mail_create_nolog": True, - "mail_create_nosubscribe": True, - "mail_notrack": True, - "no_reset_password": True, - } - self.user = new_test_user( - self.env, - login="test-user", - context=ctx, - ) - test_1 = self._create_attachment(self.env, self.user, "test1.txt") - test_2 = self._create_attachment(self.env, self.user, "test2.txt") - self.attachments = test_1 + test_2 + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.user = new_test_user(cls.env, login="test-user") + test_1 = cls._create_attachment(cls.user, "test1.txt") + test_2 = cls._create_attachment(cls.user, "test2.txt") + cls.attachments = test_1 + test_2 def test_action_attachments_download(self): self.authenticate("test-user", "test-user") @@ -49,27 +41,19 @@ def test_action_attachments_download(self): self.assertEqual(response.status_code, 200) -class TestAttachmentZipped(SavepointCase, TestAttachmentZippedDownloadBase): +class TestAttachmentZipped(TestAttachmentZippedDownloadBase): @classmethod def setUpClass(cls): super().setUpClass() - ctx = { - "mail_create_nolog": True, - "mail_create_nosubscribe": True, - "mail_notrack": True, - "no_reset_password": True, - } cls.user = new_test_user( cls.env, login="test-user", password="test-user", groups="base.group_user,base.group_partner_manager", - context=ctx, ) - test_1 = cls._create_attachment(cls.env, cls.user, "test1.txt") - test_2 = cls._create_attachment(cls.env, cls.user, "test2.txt") + test_1 = cls._create_attachment(cls.user, "test1.txt") + test_2 = cls._create_attachment(cls.user, "test2.txt") test_3 = cls._create_attachment( - cls.env, cls.user, "test3.txt", model="res.partner", @@ -83,7 +67,6 @@ def test_create_temp_zip(self): def test_create_temp_zip_access_denined(self): attachments = self.attachments | self._create_attachment( - self.env, self.uid, "test4.txt", model="ir.ui.view", diff --git a/attachment_zipped_download/tests/test_ir_attachment_action_download.py b/attachment_zipped_download/tests/test_ir_attachment_action_download.py index 5a5dc988cb0..95db89e1ca8 100644 --- a/attachment_zipped_download/tests/test_ir_attachment_action_download.py +++ b/attachment_zipped_download/tests/test_ir_attachment_action_download.py @@ -3,12 +3,10 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo_test_helper import FakeModelLoader -from odoo.tests import SavepointCase - from .test_attachment_zipped_download import TestAttachmentZippedDownloadBase -class TestMixin(SavepointCase, TestAttachmentZippedDownloadBase): +class TestMixin(TestAttachmentZippedDownloadBase): @classmethod def setUpClass(cls): super().setUpClass() @@ -21,26 +19,23 @@ def setUpClass(cls): cls.loader.update_registry((ResPartner,)) - cls.partner_1 = cls.env.ref("base.res_partner_1") - cls.partner_2 = cls.env.ref("base.res_partner_2") - cls.partner_3 = cls.env.ref("base.res_partner_3") + cls.partner_1 = cls.env["res.partner"].create({"name": "Test partner 1"}) + cls.partner_2 = cls.env["res.partner"].create({"name": "Test partner 2"}) + cls.partner_3 = cls.env["res.partner"].create({"name": "Test partner 3"}) cls.partner_1_f1 = cls._create_attachment( - cls.env, cls.env.uid, "partner_1-f1.txt", model="res.partner", res_id=cls.partner_1.id, ) cls.partner_1_f2 = cls._create_attachment( - cls.env, cls.env.uid, "partner_1-f2.txt", model="res.partner", res_id=cls.partner_1.id, ) cls.partner_2_f1 = cls._create_attachment( - cls.env, cls.env.uid, "partner_2-f1.txt", model="res.partner",