From 4fcf649dcbd2aaecdd7b1188291f9697d446a960 Mon Sep 17 00:00:00 2001 From: Yann Papouin Date: Wed, 29 Mar 2023 10:05:25 +0200 Subject: [PATCH] [PR #463] [IMP] helpdesk_mgmt: Generate `access_token` for all attachments added on ticket submit Otherwise they stay "private" and are not displayed on the portal. --- helpdesk_mgmt/controllers/main.py | 5 ++++- helpdesk_mgmt/views/helpdesk_ticket_templates.xml | 14 ++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/helpdesk_mgmt/controllers/main.py b/helpdesk_mgmt/controllers/main.py index 4c43176d0c..0fe3799d4f 100644 --- a/helpdesk_mgmt/controllers/main.py +++ b/helpdesk_mgmt/controllers/main.py @@ -91,10 +91,12 @@ def submit_ticket(self, **kw): new_ticket = request.env["helpdesk.ticket"].sudo().create(vals) new_ticket.message_subscribe(partner_ids=request.env.user.partner_id.ids) if kw.get("attachment"): + IrAttachment = request.env["ir.attachment"] + attachment_ids = IrAttachment for c_file in request.httprequest.files.getlist("attachment"): data = c_file.read() if c_file.filename: - request.env["ir.attachment"].sudo().create( + attachment_ids += IrAttachment.sudo().create( { "name": c_file.filename, "datas": base64.b64encode(data), @@ -102,4 +104,5 @@ def submit_ticket(self, **kw): "res_id": new_ticket.id, } ) + attachment_ids.sudo().generate_access_token() return werkzeug.utils.redirect("/my/ticket/%s" % new_ticket.id) diff --git a/helpdesk_mgmt/views/helpdesk_ticket_templates.xml b/helpdesk_mgmt/views/helpdesk_ticket_templates.xml index 832a95934f..10d1e112dd 100644 --- a/helpdesk_mgmt/views/helpdesk_ticket_templates.xml +++ b/helpdesk_mgmt/views/helpdesk_ticket_templates.xml @@ -298,15 +298,13 @@ for="attachment" >Add Attachments
-
-
+ class="form-control o_website_form_input" + name="attachment" + id="attachment" + type="file" + multiple="multiple" + />