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

View File

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

View File

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