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

@@ -17,6 +17,8 @@ place and the surfaces never drift apart.
import logging
from datetime import timedelta
from markupsafe import Markup
from odoo import _, api, fields, models
from odoo.exceptions import UserError
@@ -171,13 +173,14 @@ class FusionRepairIntakeService(models.AbstractModel):
# Audit message in chatter.
repair.message_post(
body=_(
body=Markup(_(
'Service call submitted via <b>%(source)s</b> by %(user)s. '
'Session reference: %(ref)s.',
source=dict(repair._fields['x_fc_intake_source'].selection).get(source),
user=intake_user.name,
ref=session_ref,
),
'Session reference: %(ref)s.'
)) % {
'source': dict(repair._fields['x_fc_intake_source'].selection).get(source) or '',
'user': intake_user.name or '',
'ref': session_ref or '',
},
)
return repair
@@ -235,12 +238,13 @@ class FusionRepairIntakeService(models.AbstractModel):
if not warranty:
return
repair.message_post(
body=_(
body=Markup(_(
'This repair MAY be covered by our active warranty <b>%(ref)s</b> '
'(expires %(exp)s). Manager review recommended before invoicing.',
ref=warranty.name,
exp=warranty.expiry_date,
),
'(expires %(exp)s). Manager review recommended before invoicing.'
)) % {
'ref': warranty.name or '',
'exp': warranty.expiry_date and str(warranty.expiry_date) or '',
},
message_type='comment',
)