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 — MRP Bridge",
|
||||
'version': '19.0.6.1.0',
|
||||
'version': '19.0.6.2.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Bridge Fusion Plating facilities, baths and tanks to Odoo MRP work orders.',
|
||||
'description': """
|
||||
|
||||
@@ -13,6 +13,8 @@ Shop Roles automatically. The operator never has to fill in a form;
|
||||
their growing skill set just unlocks itself.
|
||||
"""
|
||||
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
|
||||
@@ -160,13 +162,14 @@ class FpOperatorProficiency(models.Model):
|
||||
'x_fc_work_role_ids': [(4, role.id)],
|
||||
})
|
||||
employee.message_post(
|
||||
body=_(
|
||||
body=Markup(_(
|
||||
'🎉 <b>%(name)s promoted</b> — qualified for '
|
||||
'<b>%(role)s</b> after %(count)s successful '
|
||||
'completions.',
|
||||
name=employee.name,
|
||||
role=role.name,
|
||||
count=rec.completed_count,
|
||||
),
|
||||
'completions.'
|
||||
)) % {
|
||||
'name': employee.name,
|
||||
'role': role.name,
|
||||
'count': rec.completed_count,
|
||||
},
|
||||
subtype_xmlid='mail.mt_note',
|
||||
)
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
@@ -423,7 +425,7 @@ class MrpProduction(models.Model):
|
||||
steps_txt = wo_steps.get(wo.sequence)
|
||||
if steps_txt:
|
||||
wo.message_post(
|
||||
body=_('<b>Recipe steps:</b><br/><pre>%s</pre>') % steps_txt,
|
||||
body=Markup(_('<b>Recipe steps:</b><br/><pre>%s</pre>')) % steps_txt,
|
||||
subtype_xmlid='mail.mt_note',
|
||||
)
|
||||
production.message_post(
|
||||
|
||||
@@ -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, _
|
||||
|
||||
|
||||
@@ -86,8 +88,8 @@ class SaleOrder(models.Model):
|
||||
# Don't block SO confirm — log + continue. The manager
|
||||
# can still create the MO manually.
|
||||
so.message_post(
|
||||
body=_('Auto-MO creation failed: <code>%s</code>. '
|
||||
'Create the MO manually from MRP.') % exc,
|
||||
body=Markup(_('Auto-MO creation failed: <code>%s</code>. '
|
||||
'Create the MO manually from MRP.')) % exc,
|
||||
)
|
||||
return res
|
||||
|
||||
@@ -145,11 +147,11 @@ class SaleOrder(models.Model):
|
||||
if recipe and 'x_fc_recipe_id' in Production._fields:
|
||||
mo_vals['x_fc_recipe_id'] = recipe.id
|
||||
mo = Production.create(mo_vals)
|
||||
self.message_post(body=_(
|
||||
self.message_post(body=Markup(_(
|
||||
'Draft Manufacturing Order <a href="/odoo/manufacturing/%s">%s</a> '
|
||||
'auto-created. Accept the parts and click <b>Assign to Me</b> to '
|
||||
'release it to the floor.'
|
||||
) % (mo.id, mo.name))
|
||||
)) % (mo.id, mo.name))
|
||||
|
||||
@api.depends(
|
||||
'state', 'invoice_status',
|
||||
@@ -182,17 +184,22 @@ class SaleOrder(models.Model):
|
||||
))
|
||||
|
||||
# Paid vs invoiced
|
||||
if so.invoice_status == 'invoiced' and so.invoice_ids:
|
||||
latest = so.invoice_ids.filtered(lambda i: i.state == 'posted')
|
||||
all_paid = latest and all(
|
||||
i.payment_state in ('paid', 'in_payment') for i in latest
|
||||
)
|
||||
if shipped and all_paid:
|
||||
so.x_fc_workflow_stage = 'complete'
|
||||
continue
|
||||
if all_paid and not shipped:
|
||||
so.x_fc_workflow_stage = 'paid'
|
||||
continue
|
||||
posted_invoices = so.invoice_ids.filtered(lambda i: i.state == 'posted')
|
||||
has_posted_invoice = bool(posted_invoices)
|
||||
all_paid = has_posted_invoice and all(
|
||||
i.payment_state in ('paid', 'in_payment') for i in posted_invoices
|
||||
)
|
||||
if shipped and all_paid:
|
||||
so.x_fc_workflow_stage = 'complete'
|
||||
continue
|
||||
if all_paid and not shipped:
|
||||
so.x_fc_workflow_stage = 'paid'
|
||||
continue
|
||||
# Once an invoice is posted (regardless of payment), the SO has
|
||||
# moved past 'shipped' — the action is on accounting, not us.
|
||||
if shipped and has_posted_invoice:
|
||||
so.x_fc_workflow_stage = 'invoicing'
|
||||
continue
|
||||
|
||||
if shipped:
|
||||
so.x_fc_workflow_stage = 'shipped'
|
||||
@@ -263,7 +270,7 @@ class SaleOrder(models.Model):
|
||||
if 'x_fc_assigned_manager_id' in mo._fields and not mo.x_fc_assigned_manager_id:
|
||||
mo.x_fc_assigned_manager_id = user.id
|
||||
self.message_post(
|
||||
body=_('Job assigned to <b>%s</b>. %d MO(s) released to the floor.')
|
||||
body=Markup(_('Job assigned to <b>%s</b>. %d MO(s) released to the floor.'))
|
||||
% (user.name, len(mos)),
|
||||
)
|
||||
return True
|
||||
|
||||
@@ -92,12 +92,15 @@
|
||||
help="Close the open delivery record(s) and fire auto-invoice per strategy."/>
|
||||
</xpath>
|
||||
|
||||
<!-- Show the workflow stage on the sheet so users always
|
||||
know what step they're on (readonly banner). -->
|
||||
<xpath expr="//sheet" position="inside">
|
||||
<!-- Workflow stage banner — sits ABOVE the form header so it's
|
||||
the first thing users see, matches the Account Hold banner.
|
||||
Hidden for terminal states (invoicing/paid/complete/cancelled)
|
||||
and the initial draft so it only shows when there's an
|
||||
active in-progress step. -->
|
||||
<xpath expr="//form/header" position="before">
|
||||
<div class="alert alert-info mb-2"
|
||||
style="border-radius: 6px;"
|
||||
invisible="x_fc_workflow_stage in ('draft', 'complete', 'cancelled')">
|
||||
invisible="x_fc_workflow_stage in ('draft', 'invoicing', 'paid', 'complete', 'cancelled')">
|
||||
<i class="fa fa-compass me-2"/>
|
||||
<strong>Current stage:</strong>
|
||||
<field name="x_fc_workflow_stage" readonly="1" nolabel="1" class="ms-1"/>
|
||||
|
||||
Reference in New Issue
Block a user