Skip to content

Commit

Permalink
[PR OCA#463] [IMP] helpdesk_mgmt: Show attachments on portal's ticket…
Browse files Browse the repository at this point in the history
… view

Forward port of 656c2d9

Note that the commit fc3905e (allow portal users to write tickets) has not been forward ported as it is not necessary
  • Loading branch information
eLBati authored and PicchiSeba committed Apr 29, 2024
1 parent 0cbb920 commit 1791dce
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
11 changes: 11 additions & 0 deletions helpdesk_mgmt/controllers/myaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,21 @@ def _ticket_get_page_view_values(self, ticket, **kwargs):
closed_stages = request.env["helpdesk.ticket.stage"].search(
[("closed", "=", True)]
)
files = (
request.env["ir.attachment"]
.sudo()
.search(
[
("res_model", "=", "helpdesk.ticket"),
("res_id", "=", ticket.id),
]
)
)
values = {
"page_name": "ticket",
"ticket": ticket,
"closed_stages": closed_stages,
"files": files,
}

if kwargs.get("error"):
Expand Down
31 changes: 23 additions & 8 deletions helpdesk_mgmt/views/helpdesk_ticket_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
<t t-set="breadcrumbs_searchbar" t-value="True" />
<form method="POST" t-attf-action="/new/ticket">
<h3>Tickets
<t t-call="portal.portal_searchbar" />
<button
<t t-call="portal.portal_searchbar" />
<button
name="create_new_ticket"
type="action"
class="btn btn-primary"
style="float: right; margin-right: 5px;"
>New Ticket</button>
</h3>
</h3>
<input
type="hidden"
name="csrf_token"
Expand Down Expand Up @@ -184,13 +184,28 @@
<strong>Last Stage Update:</strong>
<span t-field="ticket.last_stage_update" />
<br />
<strong>Attachments:</strong>
<br />
<t t-foreach="files" t-as="f">
<t t-if="f.access_token">
<a
t-attf-href="/web/content/#{f.id}?download=true&amp;access_token=#{f.access_token}"
target="_blank"
>
<span class="fa fa-download" />
<span t-esc="f.name" />
</a>
<br />
</t>
</t>
</div>
</div>
<div class="row mt8">
<div class="col-md-12">
<h4 class="page-header">Description</h4>
<t t-raw="ticket.description" /><br />
</div>
</div>
<br />
<br />
<h4 class="page-header">Description</h4>
<t t-raw="ticket.description" />
<br />
</div>
<h4 class="page-header">History</h4>
<!-- Options:Ticket Chatter: user can reply -->
Expand Down

0 comments on commit 1791dce

Please sign in to comment.