Skip to content

Commit

Permalink
[PR OCA#463] [IMP] helpdesk_mgmt: Generate access_token for all att…
Browse files Browse the repository at this point in the history
…achments added on ticket submit

Otherwise they stay "private" and are not displayed on the portal.
  • Loading branch information
ypapouin authored and renda-dev committed Jan 9, 2024
1 parent dcccbcf commit b446b4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 4 additions & 1 deletion helpdesk_mgmt/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,18 @@ 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),
"res_model": "helpdesk.ticket",
"res_id": new_ticket.id,
}
)
attachment_ids.sudo().generate_access_token()
return werkzeug.utils.redirect("/my/ticket/%s" % new_ticket.id)
14 changes: 6 additions & 8 deletions helpdesk_mgmt/views/helpdesk_ticket_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,13 @@
for="attachment"
>Add Attachments</label>
<div class="col-md-7 col-sm-8">
<div class="btn btn-default btn-file col-md-12">
<input
class="form-control o_website_form_input"
name="attachment"
id="attachment"
type="file"
multiple="multiple"
/>
</div>
class="form-control o_website_form_input"
name="attachment"
id="attachment"
type="file"
multiple="multiple"
/>
</div>
</div>
<div class="form-group">
Expand Down

0 comments on commit b446b4e

Please sign in to comment.