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:
gsinghpal
2026-05-20 22:41:17 -04:00
parent 750c7068e2
commit cb56a38680
5 changed files with 36 additions and 23 deletions

View File

@@ -20,6 +20,8 @@ On confirm:
import logging
from markupsafe import Markup
from odoo import _, api, fields, models
from odoo.exceptions import UserError
@@ -162,8 +164,9 @@ class RepairVisitReportWizard(models.TransientModel):
'x_fc_maintenance_contract_id': False,
})
repair.message_post(
body=_('Spawned follow-up repair <b>%(name)s</b> for "found another issue".',
name=stub.name),
body=Markup(_(
'Spawned follow-up repair <b>%(name)s</b> for "found another issue".'
)) % {'name': stub.name or ''},
)
# If a stub was spawned, open it directly so the tech can fill in details.