fix(fusion_repairs): chatter posts render HTML correctly via Markup
Reports of literal '<b>Client Self-Service</b>' showing in the chatter
instead of bold formatting. Cause: message_post(body=str) HTML-escapes
the string. The Odoo idiom for HTML chatter bodies is markupsafe.Markup,
with the % operator auto-escaping substitution values for XSS safety.
Fixed every message_post call:
models/intake_service.py
- 'Service call submitted via <b>...</b>' (the reported one)
- 'This repair MAY be covered by our active warranty <b>...</b>'
models/maintenance_contract.py
- 'Sent N-day maintenance reminder to <email>'
- 'Maintenance visit <b>...</b> booked from reminder link'
models/technician_task.py
- 'Rolled forward after maintenance task <b>...</b> completed'
wizard/repair_visit_report_wizard.py
- 'Spawned follow-up repair <b>...</b> for "found another issue"'
Pattern used: Markup(_('... <b>%(x)s</b> ...')) % {'x': escaped_value}.
Verified on local westin-v19 (BR-WA/RO/00026): DB row now reads
'<p>Service call submitted via <b>Client Self-Service</b> by Gurpreet
Singh. Session reference: RIS000015.</p>' which renders correctly in
the chatter UI.
Bumped to 19.0.1.0.3.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import secrets
|
||||
from datetime import timedelta
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
@@ -149,9 +150,12 @@ class FusionRepairMaintenanceContract(models.Model):
|
||||
tpl.send_mail(c.id, force_send=False)
|
||||
c.last_reminder_band = band_label
|
||||
c.message_post(
|
||||
body=_('Sent %(band)s-day maintenance reminder to %(email)s.',
|
||||
band=band_label,
|
||||
email=c.partner_id.email),
|
||||
body=Markup(_(
|
||||
'Sent %(band)s-day maintenance reminder to %(email)s.'
|
||||
)) % {
|
||||
'band': band_label,
|
||||
'email': c.partner_id.email or '',
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
continue
|
||||
@@ -181,8 +185,9 @@ class FusionRepairMaintenanceContract(models.Model):
|
||||
})
|
||||
self.booking_repair_id = repair
|
||||
self.message_post(
|
||||
body=_('Maintenance visit <b>%(ref)s</b> booked from reminder link.',
|
||||
ref=repair.name),
|
||||
body=Markup(_(
|
||||
'Maintenance visit <b>%(ref)s</b> booked from reminder link.'
|
||||
)) % {'ref': repair.name or ''},
|
||||
)
|
||||
return repair
|
||||
|
||||
|
||||
Reference in New Issue
Block a user