fix: prepend absolute base URL to rating links using new helper method in helpdesk ticket

This commit is contained in:
Suherdy Yacob 2026-05-06 14:24:51 +07:00
parent d360565e4d
commit 7efc02a656
2 changed files with 17 additions and 5 deletions

View File

@ -41,31 +41,31 @@
<table style="width:100%; text-align:center; margin-top: 1rem;"> <table style="width:100%; text-align:center; margin-top: 1rem;">
<tr> <tr>
<td style="padding: 0 8px;"> <td style="padding: 0 8px;">
<a t-attf-href="/rating/{{ access_token }}/1" style="text-decoration: none; font-size: 48px; color: #FFD700; display: inline-block; transition: transform 0.2s;"> <a t-attf-href="{{ object.get_base_url() }}/rating/{{ access_token }}/1" style="text-decoration: none; font-size: 48px; color: #FFD700; display: inline-block; transition: transform 0.2s;">
</a> </a>
<div style="font-size: 11px; color: #666; margin-top: 4px;">Poor</div> <div style="font-size: 11px; color: #666; margin-top: 4px;">Poor</div>
</td> </td>
<td style="padding: 0 8px;"> <td style="padding: 0 8px;">
<a t-attf-href="/rating/{{ access_token }}/2" style="text-decoration: none; font-size: 48px; color: #FFD700; display: inline-block; transition: transform 0.2s;"> <a t-attf-href="{{ object.get_base_url() }}/rating/{{ access_token }}/2" style="text-decoration: none; font-size: 48px; color: #FFD700; display: inline-block; transition: transform 0.2s;">
</a> </a>
<div style="font-size: 11px; color: #666; margin-top: 4px;">Fair</div> <div style="font-size: 11px; color: #666; margin-top: 4px;">Fair</div>
</td> </td>
<td style="padding: 0 8px;"> <td style="padding: 0 8px;">
<a t-attf-href="/rating/{{ access_token }}/3" style="text-decoration: none; font-size: 48px; color: #FFD700; display: inline-block; transition: transform 0.2s;"> <a t-attf-href="{{ object.get_base_url() }}/rating/{{ access_token }}/3" style="text-decoration: none; font-size: 48px; color: #FFD700; display: inline-block; transition: transform 0.2s;">
</a> </a>
<div style="font-size: 11px; color: #666; margin-top: 4px;">Good</div> <div style="font-size: 11px; color: #666; margin-top: 4px;">Good</div>
</td> </td>
<td style="padding: 0 8px;"> <td style="padding: 0 8px;">
<a t-attf-href="/rating/{{ access_token }}/4" style="text-decoration: none; font-size: 48px; color: #FFD700; display: inline-block; transition: transform 0.2s;"> <a t-attf-href="{{ object.get_base_url() }}/rating/{{ access_token }}/4" style="text-decoration: none; font-size: 48px; color: #FFD700; display: inline-block; transition: transform 0.2s;">
</a> </a>
<div style="font-size: 11px; color: #666; margin-top: 4px;">Very Good</div> <div style="font-size: 11px; color: #666; margin-top: 4px;">Very Good</div>
</td> </td>
<td style="padding: 0 8px;"> <td style="padding: 0 8px;">
<a t-attf-href="/rating/{{ access_token }}/5" style="text-decoration: none; font-size: 48px; color: #FFD700; display: inline-block; transition: transform 0.2s;"> <a t-attf-href="{{ object.get_base_url() }}/rating/{{ access_token }}/5" style="text-decoration: none; font-size: 48px; color: #FFD700; display: inline-block; transition: transform 0.2s;">
</a> </a>
<div style="font-size: 11px; color: #666; margin-top: 4px;">Excellent</div> <div style="font-size: 11px; color: #666; margin-top: 4px;">Excellent</div>

View File

@ -12,6 +12,18 @@ class HelpdeskTicket(models.Model):
help='HTML representation of rating stars' help='HTML representation of rating stars'
) )
def get_base_url(self):
"""
Returns the base URL for the current record, prioritizing the domain
of the website associated with the helpdesk team.
"""
self.ensure_one()
# Check if website_id exists on team_id (added by website_helpdesk)
# and if it has a domain configured.
if 'website_id' in self.team_id._fields and self.team_id.website_id.domain:
return self.team_id.website_id.domain.rstrip('/')
return super().get_base_url()
@api.depends('rating_ids', 'rating_ids.rating', 'rating_ids.create_date', 'rating_count') @api.depends('rating_ids', 'rating_ids.rating', 'rating_ids.create_date', 'rating_count')
def _compute_rating_stars_html(self): def _compute_rating_stars_html(self):
"""Compute HTML representation of rating stars""" """Compute HTML representation of rating stars"""