Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b55bd43
[ADD] attachment_zipped_download: New addon.
victoralmau Mar 15, 2022
f0edf56
[16.0][MIG] attachment_zipped_download: Migration to 16.0
FernandoRomera Dec 16, 2022
cecd576
Added translation using Weblate (Italian)
mymage Dec 28, 2022
34261c7
[FIX] attachment_zipped_download: Fix tests
victoralmau Jan 24, 2023
d3e5a8a
Translated using Weblate (Italian)
francesco-ooops Jan 30, 2023
e4ca6d1
Added translation using Weblate (Croatian)
badbole Feb 15, 2023
7e1254d
[FIX] attachment_zipped_download: zip allowed document only
petrus-v Apr 28, 2023
0d8bf29
[IMP] attachment_zipped_download: provide ir.attachment.action_downlo…
petrus-v Apr 28, 2023
0418729
Translated using Weblate (Spanish)
Ivorra78 Sep 7, 2023
1020080
[FIX] attachment_zipped_download: fix stream download
len-foss Sep 8, 2023
17c240c
Translated using Weblate (Italian)
mymage Sep 20, 2023
ff25359
Updated from template
ivs-cetmix Nov 6, 2023
988a568
Added translation using Weblate (Portuguese)
peterromao Feb 28, 2024
93515cb
[FIX] linting after update dotfiles
StefanRijnhart Jul 4, 2024
c2c3e69
[IMP] attachment_zipped_download: pre-commit auto fixes
victoralmau Dec 18, 2024
8a3d4c3
[MIG] attachment_zipped_download: Migration to 17.0
victoralmau Dec 18, 2024
01f633d
[MIG] attachment_zipped_download: Migration to 18.0
victoralmau Jan 28, 2025
ad2bab4
[UPD] Update attachment_zipped_download.pot
Feb 18, 2025
6d57515
[BOT] post-merge updates
OCA-git-bot Feb 18, 2025
5979ea8
Update translation files
weblate Feb 18, 2025
8f77dc7
Added translation using Weblate (Portuguese (Brazil))
marcelsavegnago May 13, 2025
14dc826
[MIG] attachment_zipped_download: Migration to 19.0
gregory-rutecki Mar 16, 2026
46b1b5a
[FIX] attachment_zipped_download: prefer-env-translation
gregory-rutecki Mar 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions attachment_zipped_download/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
==========================
Attachment Zipped Download
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:fbdb4e46ccbc9603a62727e5f0d60de09598e65070309e84de2095cfb922767f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
:target: https://github.com/OCA/knowledge/tree/18.0/attachment_zipped_download
:alt: OCA/knowledge
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-attachment_zipped_download
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows downloading multiple attachments as a zip file.

This also provide a helper class IrAttachmentActionDownloadMixin to be
used by developer to add action method on models.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Go to *Settings > Technical > Database Structure > Attachments* and
select some files.
2. Go to *Actions > Download* and a zip file containing the selected
files will be downloaded.

## For developer

You can reuse the IrAttachmentActionDownloadMixin on your favorite
models:

::

from odoo import models


class StockPicking(models.Model):
_name = "stock.picking"
_inherit = ["stock.picking", "ir.attachment.action_download"]

Then you can add an action button on list view line or on the action
button (when multiple lines are selected) to download all files:

::

<odoo>
<!--
add a button on list view to download all attachement present
on the given transfert
-->
<record id="vpicktree" model="ir.ui.view">
<field name="inherit_id" ref="stock.vpicktree"/>
<field name="name">stock.picking.tree download attachments</field>
<field name="model">stock.picking</field>
<field name="arch" type="xml">
<field name="json_popover" position="after">
<button name="action_download_attachments"
type="object"
icon="fa-download"
string="Download attachment(s)"
aria-label="Download Proof documents"
class="float-right"/>
</field>
</field>
</record>

<!--
Add "Download attachments" item in the Action menu when
multiple records are selected
-->
<record id="action_download_picking_attachements" model="ir.actions.server">
<field name="name">Download attachments</field>
<field name="model_id" ref="stock.model_stock_picking"/>
<field name="binding_model_id" ref="stock.model_stock_picking"/>
<field name="binding_view_types">list</field>
<field name="state">code</field>
<field name="code">
action = records.action_download_attachments()
</field>
</record>
</odoo>

.. note::

Even you will be able to generate a zip file with multiple document
with the same name it's advice to overwrite \_compute_zip_file_name
to improve the name. When a slash (/) is present in the path it will
create a directory. This example will create a directory per
stock.picking using its name:

::

class IrAttachment(models.Model):
_inherit = "ir.attachment"

def _compute_zip_file_name(self):
self.ensure_one()
if self.res_model and self.res_model == "stock.picking":
return (
self.env[self.res_model]
.browse(self.res_id)
.display_name.replace("/", "-")
+ "/"
+ self.name
)
return super()._compute_zip_file_name()

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_zipped_download%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Tecnativa

Contributors
------------

- César Fernández Domínguez <cesfernandez@outlook.com>
- `Tecnativa <https://www.tecnativa.com>`__:

- Víctor Martínez
- Pedro M. Baeza

- Pierre Verkest <pierreverkest@gmail.com>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/18.0/attachment_zipped_download>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions attachment_zipped_download/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
15 changes: 15 additions & 0 deletions attachment_zipped_download/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Attachment Zipped Download",
"version": "19.0.1.0.0",
"category": "Tools",
"website": "https://github.com/OCA/knowledge",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["base"],
"data": [
"views/ir_attachment_view.xml",
],
"installable": True,
}
1 change: 1 addition & 0 deletions attachment_zipped_download/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
23 changes: 23 additions & 0 deletions attachment_zipped_download/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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"].browse(list_ids)._create_temp_zip()
stream = http.Stream(
type="data",
data=out_file.getvalue(),
mimetype="application/zip",
as_attachment=True,
download_name=request.env._("attachments.zip"),
)
return stream.get_response()
56 changes: 56 additions & 0 deletions attachment_zipped_download/i18n/attachment_zipped_download.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attachment_zipped_download
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: attachment_zipped_download
#: model:ir.model,name:attachment_zipped_download.model_ir_attachment_action_download
msgid ""
"\n"
" Mixin to help download attachments linked to record(s).\n"
" "
msgstr ""

#. module: attachment_zipped_download
#: model:ir.model,name:attachment_zipped_download.model_ir_attachment
msgid "Attachment"
msgstr ""

#. module: attachment_zipped_download
#: model:ir.actions.server,name:attachment_zipped_download.action_attachments_download
msgid "Download"
msgstr ""

#. module: attachment_zipped_download
#. odoo-python
#: code:addons/attachment_zipped_download/models/ir_attachment_action_download.py:0
msgid "No attachment!"
msgstr ""

#. module: attachment_zipped_download
#. odoo-python
#: code:addons/attachment_zipped_download/models/ir_attachment.py:0
msgid "None attachment selected. Only binary attachments allowed."
msgstr ""

#. module: attachment_zipped_download
#. odoo-python
#: code:addons/attachment_zipped_download/models/ir_attachment_action_download.py:0
msgid "There is no document found to download."
msgstr ""

#. module: attachment_zipped_download
#. odoo-python
#: code:addons/attachment_zipped_download/controllers/main.py:0
msgid "attachments.zip"
msgstr ""
66 changes: 66 additions & 0 deletions attachment_zipped_download/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attachment_zipped_download
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-15 14:04+0000\n"
"PO-Revision-Date: 2023-09-07 16:37+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: attachment_zipped_download
#: model:ir.model,name:attachment_zipped_download.model_ir_attachment_action_download
msgid ""
"\n"
" Mixin to help download attachments linked to record(s).\n"
" "
msgstr ""
"\n"
" Mixin para ayudar a descargar archivos adjuntos vinculados a "
"registros.\n"
" "

#. module: attachment_zipped_download
#: model:ir.model,name:attachment_zipped_download.model_ir_attachment
msgid "Attachment"
msgstr "Adjunto"

#. module: attachment_zipped_download
#: model:ir.actions.server,name:attachment_zipped_download.action_attachments_download
msgid "Download"
msgstr "Descargar"

#. module: attachment_zipped_download
#. odoo-python
#: code:addons/attachment_zipped_download/models/ir_attachment_action_download.py:0
msgid "No attachment!"
msgstr "¡No hay adjuntos!"

#. module: attachment_zipped_download
#. odoo-python
#: code:addons/attachment_zipped_download/models/ir_attachment.py:0
msgid "None attachment selected. Only binary attachments allowed."
msgstr ""
"No se seleccionó ningún archivo adjunto. Solo se permiten archivos adjuntos "
"binarios."

#. module: attachment_zipped_download
#. odoo-python
#: code:addons/attachment_zipped_download/models/ir_attachment_action_download.py:0
msgid "There is no document found to download."
msgstr "No se encontró ningún documento para descargar."

#. module: attachment_zipped_download
#. odoo-python
#: code:addons/attachment_zipped_download/controllers/main.py:0
msgid "attachments.zip"
msgstr "adjuntos.zip"
Loading
Loading