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:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Fusion Repairs',
|
'name': 'Fusion Repairs',
|
||||||
'version': '19.0.1.0.2',
|
'version': '19.0.1.0.3',
|
||||||
'category': 'Inventory/Repairs',
|
'category': 'Inventory/Repairs',
|
||||||
'summary': 'Guided medical equipment repair intake, dispatch, maintenance, and self-service portal',
|
'summary': 'Guided medical equipment repair intake, dispatch, maintenance, and self-service portal',
|
||||||
'description': """
|
'description': """
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ place and the surfaces never drift apart.
|
|||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
|
from markupsafe import Markup
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
@@ -171,13 +173,14 @@ class FusionRepairIntakeService(models.AbstractModel):
|
|||||||
|
|
||||||
# Audit message in chatter.
|
# Audit message in chatter.
|
||||||
repair.message_post(
|
repair.message_post(
|
||||||
body=_(
|
body=Markup(_(
|
||||||
'Service call submitted via <b>%(source)s</b> by %(user)s. '
|
'Service call submitted via <b>%(source)s</b> by %(user)s. '
|
||||||
'Session reference: %(ref)s.',
|
'Session reference: %(ref)s.'
|
||||||
source=dict(repair._fields['x_fc_intake_source'].selection).get(source),
|
)) % {
|
||||||
user=intake_user.name,
|
'source': dict(repair._fields['x_fc_intake_source'].selection).get(source) or '',
|
||||||
ref=session_ref,
|
'user': intake_user.name or '',
|
||||||
),
|
'ref': session_ref or '',
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return repair
|
return repair
|
||||||
@@ -235,12 +238,13 @@ class FusionRepairIntakeService(models.AbstractModel):
|
|||||||
if not warranty:
|
if not warranty:
|
||||||
return
|
return
|
||||||
repair.message_post(
|
repair.message_post(
|
||||||
body=_(
|
body=Markup(_(
|
||||||
'This repair MAY be covered by our active warranty <b>%(ref)s</b> '
|
'This repair MAY be covered by our active warranty <b>%(ref)s</b> '
|
||||||
'(expires %(exp)s). Manager review recommended before invoicing.',
|
'(expires %(exp)s). Manager review recommended before invoicing.'
|
||||||
ref=warranty.name,
|
)) % {
|
||||||
exp=warranty.expiry_date,
|
'ref': warranty.name or '',
|
||||||
),
|
'exp': warranty.expiry_date and str(warranty.expiry_date) or '',
|
||||||
|
},
|
||||||
message_type='comment',
|
message_type='comment',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import secrets
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
|
from markupsafe import Markup
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
|
|
||||||
@@ -149,9 +150,12 @@ class FusionRepairMaintenanceContract(models.Model):
|
|||||||
tpl.send_mail(c.id, force_send=False)
|
tpl.send_mail(c.id, force_send=False)
|
||||||
c.last_reminder_band = band_label
|
c.last_reminder_band = band_label
|
||||||
c.message_post(
|
c.message_post(
|
||||||
body=_('Sent %(band)s-day maintenance reminder to %(email)s.',
|
body=Markup(_(
|
||||||
band=band_label,
|
'Sent %(band)s-day maintenance reminder to %(email)s.'
|
||||||
email=c.partner_id.email),
|
)) % {
|
||||||
|
'band': band_label,
|
||||||
|
'email': c.partner_id.email or '',
|
||||||
|
},
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
@@ -181,8 +185,9 @@ class FusionRepairMaintenanceContract(models.Model):
|
|||||||
})
|
})
|
||||||
self.booking_repair_id = repair
|
self.booking_repair_id = repair
|
||||||
self.message_post(
|
self.message_post(
|
||||||
body=_('Maintenance visit <b>%(ref)s</b> booked from reminder link.',
|
body=Markup(_(
|
||||||
ref=repair.name),
|
'Maintenance visit <b>%(ref)s</b> booked from reminder link.'
|
||||||
|
)) % {'ref': repair.name or ''},
|
||||||
)
|
)
|
||||||
return repair
|
return repair
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
# Copyright 2024-2026 Nexa Systems Inc.
|
# Copyright 2024-2026 Nexa Systems Inc.
|
||||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||||
|
|
||||||
|
from markupsafe import Markup
|
||||||
|
|
||||||
from odoo import fields, models
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
@@ -47,11 +49,10 @@ class FusionTechnicianTaskRepairs(models.Model):
|
|||||||
try:
|
try:
|
||||||
contract.last_service_date = fields.Date.context_today(task)
|
contract.last_service_date = fields.Date.context_today(task)
|
||||||
contract.roll_next_due_date()
|
contract.roll_next_due_date()
|
||||||
contract.message_post(body=(
|
contract.message_post(body=Markup(
|
||||||
'Rolled forward after maintenance task '
|
'Rolled forward after maintenance task '
|
||||||
f'<b>{task.name}</b> completed. '
|
'<b>%s</b> completed. Next due %s.'
|
||||||
f'Next due {contract.next_due_date}.'
|
) % (task.name or '', str(contract.next_due_date or '')))
|
||||||
))
|
|
||||||
except Exception:
|
except Exception:
|
||||||
# Never let a contract roll failure block the task write.
|
# Never let a contract roll failure block the task write.
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ On confirm:
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from markupsafe import Markup
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
@@ -162,8 +164,9 @@ class RepairVisitReportWizard(models.TransientModel):
|
|||||||
'x_fc_maintenance_contract_id': False,
|
'x_fc_maintenance_contract_id': False,
|
||||||
})
|
})
|
||||||
repair.message_post(
|
repair.message_post(
|
||||||
body=_('Spawned follow-up repair <b>%(name)s</b> for "found another issue".',
|
body=Markup(_(
|
||||||
name=stub.name),
|
'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.
|
# If a stub was spawned, open it directly so the tech can fill in details.
|
||||||
|
|||||||
Reference in New Issue
Block a user