From ed3adc2dbe7d200373e74a1f3a65c80a730cc2b5 Mon Sep 17 00:00:00 2001 From: Samir Ladoui Date: Sun, 2 Feb 2025 13:28:11 +0100 Subject: [PATCH] [FIX] dms: fix get_zip function to retrieve file_ids --- odex25_dms/dms/controllers/main.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/odex25_dms/dms/controllers/main.py b/odex25_dms/dms/controllers/main.py index f124b455b..16f3288b8 100644 --- a/odex25_dms/dms/controllers/main.py +++ b/odex25_dms/dms/controllers/main.py @@ -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//"], type='http', auth='public')