fix(plating): chatter HTML rendering + workflow stage banner UX
Two fixes from a single SO walkthrough screenshot:
**1. "Current stage" banner**
- Was placed `inside sheet` so it rendered at the BOTTOM of the form
where users miss it. Moved to `before form/header` (same xpath
pattern as the Account Hold banner) — now it's the first thing
visible above the SO header.
- Was still showing "Shipped — awaiting invoice" after the invoice
was posted because `_compute_workflow_stage` only advanced to
`complete` when shipped + ALL paid; an unpaid posted invoice left
the SO stuck on `shipped`. Added an `invoicing` branch: shipped +
has_posted_invoice → invoicing. Banner invisible-list now also
includes `invoicing` and `paid`, so the banner only shows for
in-progress steps.
**2. Chatter messages rendering raw HTML tags as text**
Odoo 19 escapes any string passed to `message_post(body=...)`
unless wrapped in `markupsafe.Markup`. We had ~10 places posting
HTML (`<a href>`, `<b>`, `<br/>`, `<code>`, `<pre>`) that all
showed up as `<a href=...>` literal text in the chatter.
Wrapped each one with `Markup(_(...))` so the tags render. Files
touched:
- fusion_plating_bridge_mrp/models/sale_order.py
(auto-MO failure code block, "Draft MO created" link,
"Job assigned to <b>" message)
- fusion_plating_bridge_mrp/models/mrp_production.py
("Recipe steps" pre/br block on each WO)
- fusion_plating_bridge_mrp/models/fp_proficiency.py
(operator promotion announcement)
- fusion_plating_configurator/models/fp_quote_configurator.py
(SO link, 3D model attached, drawing attached, save to catalog)
- fusion_plating_configurator/models/fp_part_catalog.py
(3D/drawing change tracking + propagation to linked quotes)
- fusion_plating_portal/models/fp_quote_request.py
(RFQ → SO link)
- fusion_plating_quality/models/fp_quality_hold.py
(hold status change)
- fusion_plating_shopfloor/controllers/manager_controller.py
(worker / tank / manager-takeover assignments)
Verified on entech: SO S00038 stage now reads `invoicing` (banner
hidden), and a freshly posted message shows `<a href>` and `<b>`
as actual link + bold instead of escaped text.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
'name': 'Fusion Plating — Configurator',
|
||||
'version': '19.0.5.0.0',
|
||||
'version': '19.0.5.1.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Quotation configurator with part catalog, coating configs, and formula-based pricing engine.',
|
||||
'description': """
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
@@ -235,11 +237,11 @@ class FpPartCatalog(models.Model):
|
||||
old = snap['model']
|
||||
new = rec.model_attachment_id
|
||||
if not old and new:
|
||||
messages.append(_('<b>3D model attached:</b> %s') % new.name)
|
||||
messages.append(Markup(_('<b>3D model attached:</b> %s')) % new.name)
|
||||
elif old and not new:
|
||||
messages.append(_('<b>3D model removed:</b> %s') % old.name)
|
||||
messages.append(Markup(_('<b>3D model removed:</b> %s')) % old.name)
|
||||
elif old and new and old.id != new.id:
|
||||
messages.append(_('<b>3D model changed:</b> %s → %s') % (old.name, new.name))
|
||||
messages.append(Markup(_('<b>3D model changed:</b> %s → %s')) % (old.name, new.name))
|
||||
|
||||
# Drawing changes (added or removed)
|
||||
if track_drawings:
|
||||
@@ -250,15 +252,15 @@ class FpPartCatalog(models.Model):
|
||||
for att_id in added:
|
||||
att = self.env['ir.attachment'].browse(att_id)
|
||||
if att.exists():
|
||||
messages.append(_('<b>Drawing attached:</b> %s') % att.name)
|
||||
messages.append(Markup(_('<b>Drawing attached:</b> %s')) % att.name)
|
||||
for att_id in removed:
|
||||
att = self.env['ir.attachment'].browse(att_id)
|
||||
# Browse even if deleted — may still have name if not purged
|
||||
name = att.exists() and att.name or f'#{att_id}'
|
||||
messages.append(_('<b>Drawing removed:</b> %s') % name)
|
||||
messages.append(Markup(_('<b>Drawing removed:</b> %s')) % name)
|
||||
|
||||
if messages:
|
||||
body = '<br/>'.join(messages)
|
||||
body = Markup('<br/>').join(messages)
|
||||
# Post to part catalog chatter
|
||||
rec.message_post(
|
||||
body=body,
|
||||
@@ -271,7 +273,7 @@ class FpPartCatalog(models.Model):
|
||||
])
|
||||
for cfg in configurators:
|
||||
cfg.message_post(
|
||||
body=_('Part <b>%s</b>: %s') % (rec.name, body),
|
||||
body=Markup(_('Part <b>%s</b>: %s')) % (rec.name, body),
|
||||
message_type='notification',
|
||||
subtype_xmlid='mail.mt_note',
|
||||
)
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
import math
|
||||
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
@@ -549,7 +551,7 @@ class FpQuoteConfigurator(models.Model):
|
||||
'won_date': fields.Date.today(),
|
||||
})
|
||||
self.message_post(
|
||||
body=_('Sale Order <a href="/odoo/sale-order/%s">%s</a> created.') % (so.id, so.name),
|
||||
body=Markup(_('Sale Order <a href="/odoo/sale-order/%s">%s</a> created.')) % (so.id, so.name),
|
||||
)
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
@@ -623,7 +625,7 @@ class FpQuoteConfigurator(models.Model):
|
||||
# Post to chatter so user sees confirmation (only if record is saved)
|
||||
if self.id and not isinstance(self.id, models.NewId):
|
||||
self.sudo().message_post(
|
||||
body=_('3D model attached: <b>%s</b> — surface area: %.4f %s') % (
|
||||
body=Markup(_('3D model attached: <b>%s</b> — surface area: %.4f %s')) % (
|
||||
fname, self.surface_area, self.surface_area_uom or ''),
|
||||
message_type='notification',
|
||||
subtype_xmlid='mail.mt_note',
|
||||
@@ -666,7 +668,7 @@ class FpQuoteConfigurator(models.Model):
|
||||
# Post to chatter so user sees confirmation (only if record is saved)
|
||||
if self.id and not isinstance(self.id, models.NewId):
|
||||
self.sudo().message_post(
|
||||
body=_('Drawing attached: <b>%s</b> (linked to part %s)') % (
|
||||
body=Markup(_('Drawing attached: <b>%s</b> (linked to part %s)')) % (
|
||||
fname, part.name),
|
||||
message_type='notification',
|
||||
subtype_xmlid='mail.mt_note',
|
||||
@@ -838,7 +840,7 @@ class FpQuoteConfigurator(models.Model):
|
||||
'complexity': self.complexity,
|
||||
})
|
||||
self.message_post(
|
||||
body=_('Geometry and material saved back to part catalog <b>%s</b>.') % self.part_catalog_id.name,
|
||||
body=Markup(_('Geometry and material saved back to part catalog <b>%s</b>.')) % self.part_catalog_id.name,
|
||||
message_type='notification',
|
||||
subtype_xmlid='mail.mt_note',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user