[FIX] dms: fix get_zip function to retrieve file_ids

This commit is contained in:
Samir Ladoui 2025-02-02 13:28:11 +01:00
parent 13045c5113
commit ed3adc2dbe
1 changed files with 20 additions and 5 deletions

View File

@ -289,16 +289,31 @@ class ShareRoute(http.Controller):
return response
@http.route(['/document/zip'], type='http', auth='user')
def get_zip(self, file_ids, zip_name, token=None):
"""route to get the zip file of the selection in the document's Kanban view (Document inspector).
:param file_ids: if of the files to zip.
:param zip_name: name of the zip file.
def get_zip(self, file_ids=None, zip_name=None, token=None, **kwargs):
"""Route to get the zip file of the selection in the document's Kanban view.
:param file_ids: IDs of the files to zip (either comma-separated or list format).
:param zip_name: Name of the zip file.
:param token: Optional token for file tracking.
"""
ids_list = [int(x) for x in file_ids.split(',')]
if not file_ids:
# If file_ids is None, check for list-style query parameters
file_ids = request.httprequest.args.getlist('file_ids[]')
if file_ids:
if isinstance(file_ids, list): # Case: file_ids[]=1262&file_ids[]=1256
ids_list = [int(x) for x in file_ids]
else: # Case: file_ids=1262,1256,1261
ids_list = [int(x) for x in file_ids.split(',')]
else:
ids_list = []
env = request.env
response = self._make_zip(zip_name, env['documents.document'].browse(ids_list))
if token:
response.set_cookie('fileToken', token)
return response
@http.route(["/document/download/all/<int:share_id>/<access_token>"], type='http', auth='public')