knowledge/attachment_zipped_download/controllers/main.py
FernandoRomera f957b2e1b0 [16.0][MIG] attachment_zipped_download: Migration to 16.0
[UPD] Update attachment_zipped_download.pot

[UPD] README.rst

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: knowledge-16.0/knowledge-16.0-attachment_zipped_download
Translate-URL: https://translation.odoo-community.org/projects/knowledge-16-0/knowledge-16-0-attachment_zipped_download/
2025-01-28 08:25:06 +01:00

24 lines
855 B
Python

# Copyright 2019 César Fernández Domínguez <cesfernandez@outlook.com>
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import _, http
from odoo.http import request
class AttachmentZippedDownloadController(http.Controller):
@http.route("/web/attachment/download_zip", type="http", auth="user")
def download_zip(self, ids=None, debug=0):
ids = [] if not ids else ids
if len(ids) == 0:
return
list_ids = map(int, ids.split(","))
out_file = (
request.env["ir.attachment"].sudo().browse(list_ids)._create_temp_zip()
)
return http.send_file(
filepath_or_fp=out_file,
mimetype="application/zip",
as_attachment=True,
filename=_("attachments.zip"),
)