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:
@@ -2,6 +2,8 @@
|
||||
# Copyright 2024-2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
@@ -47,11 +49,10 @@ class FusionTechnicianTaskRepairs(models.Model):
|
||||
try:
|
||||
contract.last_service_date = fields.Date.context_today(task)
|
||||
contract.roll_next_due_date()
|
||||
contract.message_post(body=(
|
||||
contract.message_post(body=Markup(
|
||||
'Rolled forward after maintenance task '
|
||||
f'<b>{task.name}</b> completed. '
|
||||
f'Next due {contract.next_due_date}.'
|
||||
))
|
||||
'<b>%s</b> completed. Next due %s.'
|
||||
) % (task.name or '', str(contract.next_due_date or '')))
|
||||
except Exception:
|
||||
# Never let a contract roll failure block the task write.
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user