mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-23 21:57:44 -06:00
[IMP] attachment_zipped_download: pre-commit auto fixes
This commit is contained in:
5
attachment_zipped_download/readme/CONTRIBUTORS.md
Normal file
5
attachment_zipped_download/readme/CONTRIBUTORS.md
Normal file
@@ -0,0 +1,5 @@
|
||||
- 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>\>
|
||||
@@ -1,8 +0,0 @@
|
||||
* 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>
|
||||
4
attachment_zipped_download/readme/DESCRIPTION.md
Normal file
4
attachment_zipped_download/readme/DESCRIPTION.md
Normal file
@@ -0,0 +1,4 @@
|
||||
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.
|
||||
@@ -1,4 +0,0 @@
|
||||
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.
|
||||
@@ -1,10 +1,12 @@
|
||||
#. 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.
|
||||
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
|
||||
\## For developer
|
||||
|
||||
You can reuse the `IrAttachmentActionDownloadMixin` on your
|
||||
favorite models::
|
||||
You can reuse the IrAttachmentActionDownloadMixin on your favorite
|
||||
models:
|
||||
|
||||
from odoo import models
|
||||
|
||||
@@ -13,9 +15,8 @@ favorite models::
|
||||
_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::
|
||||
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>
|
||||
<!--
|
||||
@@ -54,25 +55,24 @@ Then you can add an action button on list view line or on the action button
|
||||
</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()
|
||||
> [!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()
|
||||
Reference in New Issue
Block a user