Skip to content

Commit

Permalink
[MIG] attachment_zipped_download: Migration to 17.0
Browse files Browse the repository at this point in the history
TT52268
  • Loading branch information
victoralmau committed Dec 18, 2024
1 parent e5387e2 commit bc9b60d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 68 deletions.
2 changes: 1 addition & 1 deletion attachment_zipped_download/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
9 changes: 0 additions & 9 deletions attachment_zipped_download/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 0 additions & 6 deletions attachment_zipped_download/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 0 additions & 9 deletions attachment_zipped_download/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
51 changes: 17 additions & 34 deletions attachment_zipped_download/tests/test_attachment_zipped_download.py
Original file line number Diff line number Diff line change
@@ -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(
{
Expand All @@ -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")
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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",
Expand Down

0 comments on commit bc9b60d

Please sign in to comment.