Browse Source

MAY 12: [FIX] Bug Fixed 'chatter_attachments_as_zip'

pull/380/head
Cybrosys Technologies 2 months ago
parent
commit
0bed166e12
  1. 2
      chatter_attachments_as_zip/__manifest__.py
  2. 16
      chatter_attachments_as_zip/controllers/chatter_attachment_as_zip.py
  3. 5
      chatter_attachments_as_zip/doc/RELEASE_NOTES.md
  4. 2
      chatter_attachments_as_zip/static/src/js/attachment_box_inherit_view.js

2
chatter_attachments_as_zip/__manifest__.py

@ -21,7 +21,7 @@
###############################################################################
{
"name": "Chatter Attachments as ZIP",
"version": "16.0.1.0.0",
"version": "16.0.1.0.1",
"category": "Extra Tools",
"summary": """Download All Chatter Attachments As A Single Zip File.""",
"description": """This module helps to download all chatter attachments

16
chatter_attachments_as_zip/controllers/chatter_attachment_as_zip.py

@ -38,12 +38,20 @@ class DownloadAllAttachments(http.Controller):
Returns:
werkzeug.wrappers.Response: HTTP response with the zip file.
"""
chatter_id = request.params.get('res_id')
attachments = request.env['ir.attachment'].search(
[('res_id', '=', chatter_id)])
res_id = request.params.get('res_id')
res_model = request.params.get('res_model')
if not res_id or not res_model:
return request.not_found()
attachments = request.env['ir.attachment'].sudo().search([
('res_id', '=', int(res_id)),
('res_model', '=', res_model),
('datas', '!=', False),
])
if attachments:
# Define the name of the zip file
zip_filename = f'attachments_{chatter_id}.zip'
zip_filename = f'attachments_{res_id}.zip'
# Create a zip file with the attachments and prepare it for download
zip_data = io.BytesIO()
with zipfile.ZipFile(zip_data, 'w', zipfile.ZIP_DEFLATED) as zipf:

5
chatter_attachments_as_zip/doc/RELEASE_NOTES.md

@ -4,3 +4,8 @@
#### Version 16.0.1.0.0
#### ADD
- Initial commit for Chatter Attachments as ZIP
#### 05.05.2025
#### Version 16.0.1.0.1
#### UPDATE
- Along with res_id, res_model is also passed and checked.

2
chatter_attachments_as_zip/static/src/js/attachment_box_inherit_view.js

@ -19,7 +19,7 @@ registerPatch({
return;
}
// Build the URL with parameters in the query string
const url = `/chatter/attachments/download/zip?res_id=${this.chatter.threadId}`;
const url = `/chatter/attachments/download/zip?res_id=${this.chatter.threadId}&res_model=${this.chatter.thread.model}`;
// Send an HTTP GET request to download attachments as a zip file
fetch(url)
.then(response => {

Loading…
Cancel
Save