[MIG] backport module attachment_zipped_download

This commit is contained in:
Yu Weng 2023-06-12 10:37:28 +02:00
parent a908fd3646
commit 1e7384bb19
3 changed files with 5 additions and 3 deletions

View File

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Attachment Zipped Download",
"version": "16.0.1.0.1",
"version": "12.0.1.0.1",
"category": "Tools",
"website": "https://github.com/OCA/knowledge",
"author": "Tecnativa, Odoo Community Association (OCA)",

View File

@ -4,13 +4,14 @@
import zipfile
from io import BytesIO
from odoo import _, models
from odoo import _, api, models
from odoo.exceptions import UserError
class IrAttachment(models.Model):
_inherit = "ir.attachment"
@api.multi
def action_attachments_download(self):
items = self.filtered(lambda x: x.type == "binary")
if not items:

View File

@ -18,6 +18,7 @@ class TestAttachmentZippedDownload(odoo.tests.HttpCase):
self.user = new_test_user(
self.env,
login="test-user",
password="test-user",
context=ctx,
)
test_1 = self._create_attachment(self.user, "test1.txt")
@ -27,7 +28,7 @@ class TestAttachmentZippedDownload(odoo.tests.HttpCase):
def _create_attachment(self, user, name):
return (
self.env["ir.attachment"]
.with_user(user)
.sudo(user)
.create(
{
"name": name,