From 9cfafbb23966e5eecddc56707a1af3b0b326c10d Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Fri, 28 Apr 2023 16:13:20 +0200 Subject: [PATCH] [IMP] attachment_zipped_download: provide ir.attachment.action_download mixin This helps to download multiple attachments from any models. [UPD] Update attachment_zipped_download.pot [UPD] README.rst attachment_zipped_download 14.0.2.0.0 [UPD] README.rst Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: knowledge-14.0/knowledge-14.0-attachment_zipped_download Translate-URL: https://translation.odoo-community.org/projects/knowledge-14-0/knowledge-14-0-attachment_zipped_download/ --- attachment_zipped_download/README.rst | 96 ++++++++++++++- attachment_zipped_download/__manifest__.py | 2 +- .../i18n/attachment_zipped_download.pot | 23 ++++ attachment_zipped_download/i18n/es.po | 27 +++- attachment_zipped_download/i18n/fr.po | 78 ++++++++++++ attachment_zipped_download/i18n/it.po | 23 ++++ attachment_zipped_download/models/__init__.py | 1 + .../models/ir_attachment_action_download.py | 55 +++++++++ .../readme/CONTRIBUTORS.rst | 2 + .../readme/DESCRIPTION.rst | 3 + attachment_zipped_download/readme/USAGE.rst | 76 ++++++++++++ .../static/description/index.html | 115 +++++++++++++++--- attachment_zipped_download/tests/__init__.py | 1 + .../tests/models/__init__.py | 0 .../tests/models/res_partner.py | 9 ++ .../test_ir_attachment_action_download.py | 81 ++++++++++++ 16 files changed, 566 insertions(+), 26 deletions(-) create mode 100644 attachment_zipped_download/i18n/fr.po create mode 100644 attachment_zipped_download/models/ir_attachment_action_download.py create mode 100644 attachment_zipped_download/tests/models/__init__.py create mode 100644 attachment_zipped_download/tests/models/res_partner.py create mode 100644 attachment_zipped_download/tests/test_ir_attachment_action_download.py diff --git a/attachment_zipped_download/README.rst b/attachment_zipped_download/README.rst index 58bb48c4..b60fce52 100644 --- a/attachment_zipped_download/README.rst +++ b/attachment_zipped_download/README.rst @@ -2,10 +2,13 @@ Attachment Zipped Download ========================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:f01e61d6df5d9f4d83daca5a9e41a5224a22debafe05c1e3ea55572df7587a51 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -19,14 +22,17 @@ Attachment Zipped Download .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png :target: https://translation.odoo-community.org/projects/knowledge-14-0/knowledge-14-0-attachment_zipped_download :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/118/14.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=14.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|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:: @@ -38,12 +44,88 @@ Usage #. Go to *Settings > Technical > Database Structure > Attachments* and select some files. #. 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:: + + + + + + stock.picking.tree download attachments + stock.picking + + +