Files
Odoo-Modules/fusion_helpdesk_central/data/mail_template_engagement.xml
gsinghpal 396170b438 feat(fusion_helpdesk): owner-approval engagement flow + AI summary + reporting
Ships the design spec at docs/superpowers/specs/2026-05-27-owner-approval-flow-design.md.

What's new on central (fusion_helpdesk_central 19.0.1.2.0 -> 19.0.2.0.0):

- Engagement model: 8 new fields on helpdesk.ticket (state, snapshotted
  owner email/name, single-use UUID4 token, sent/reminded/decided
  timestamps, AI summary, stored-computed turnaround hours).
- Wizard: single + bulk modes on one fusion.helpdesk.engagement.wizard
  TransientModel with a child wizard.line for per-ticket bulk summaries.
  default_get pulls the OpenAI summary on open; AI fan-out for bulk is
  parallel via ThreadPoolExecutor (max 5 workers, 30s overall cap).
- OpenAI client in utils.py — stdlib urllib, 15s per-call timeout, every
  failure collapses to '' so the wizard's manual-summary fallback fires.
- Public portal: /fusion_helpdesk/engagement/<token>/<decision> GET +
  POST, four branded standalone QWeb pages (confirm/done/invalid/error).
  Token is single-use, cleared on confirm. Decision posts a public
  comment attributed to the resolved owner partner; chatter propagates
  to the employee's My Tickets thread per the "fully visible" UX choice.
- Mail templates (single + bulk) with magic-link buttons. Bulk template
  renders one card per ticket, each with its own approve/reject URL.
- Reminder cron: daily, single-shot per engagement, configurable via
  fusion_helpdesk_central.engagement_reminder_days ICP (default 3, 0
  disables).
- Reporting dashboard: pivot/graph/list/kanban over helpdesk.ticket
  filtered to engaged ones, with avg-turnaround measure. Menu lives
  under Helpdesk > Reporting > Owner Engagements.
- Client_key extended with owner_email/owner_name fields; ticket.create
  upserts them from the client-side piggyback (no new sync endpoint).
- 100% coverage on utils + integration tests on wizard, controllers,
  re-engagement, cron, computed turnaround. OpenAI mocked in CI.

What's new on client (fusion_helpdesk 19.0.1.7.1 -> 19.0.2.0.0):

- Two new ICP settings: fusion_helpdesk.owner_email / .owner_name with
  a new "Owner Approval" block in Settings > Fusion Helpdesk.
- controllers/main.py::submit piggybacks both keys on every ticket
  payload so central keeps client_key.owner_email/name fresh
  automatically.

Verified live end-to-end on entech -> nexa: payload upsert, wizard with
mocked AI, action_send, portal GET/POST/GET-again cycle, second click
hits the friendly invalid-token page. Token entropy = 122 bits (UUID4).
2026-05-27 13:03:23 -04:00

170 lines
10 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2026 Nexa Systems Inc.
License OPL-1
Two mail templates for the owner-approval engagement flow:
* mail_template_engagement — single ticket
* mail_template_engagement_bulk — multiple tickets, one card per ticket,
per-ticket approve/reject buttons
Both use {{ ctx.fhc_personal_note }} + {{ ctx.fhc_is_reminder }} from the
wizard's with_context(**data) so dynamic per-send data reaches the body.
noupdate=1 so support's later tweaks (e.g. a different reply-to)
survive every fusion_helpdesk_central upgrade.
-->
<odoo>
<data noupdate="1">
<!-- ============== SINGLE TICKET ENGAGEMENT ============== -->
<record id="mail_template_engagement" model="mail.template">
<field name="name">Helpdesk: Owner Approval Request (Single)</field>
<field name="model_id" ref="helpdesk.model_helpdesk_ticket"/>
<field name="subject">{{ ctx.get('fhc_is_reminder') and 'Reminder: still waiting on your approval' or 'Action needed: please review' }} — "{{ object.name }}"</field>
<field name="email_to">{{ object.x_fc_engagement_email }}</field>
<field name="reply_to">{{ (object.user_id.email or object.team_id.alias_email or object.company_id.email or '') }}</field>
<field name="lang">en_US</field>
<field name="auto_delete" eval="True"/>
<field name="body_html" type="html">
<div style="margin:0; padding:0; font-family:Arial, Helvetica, sans-serif; color:#21252b; font-size:14px;">
<p>Hi <t t-out="object.x_fc_engagement_name or 'there'"/>,</p>
<t t-if="ctx.get('fhc_is_reminder')">
<p style="background:#fff8e6; border-left:3px solid #d4a017; padding:8px 12px; margin:12px 0;">
Following up on the request below — the original
email was sent a few days ago and we haven't
heard back yet. Same Approve / Reject buttons,
same one click.
</p>
</t>
<t t-elif="ctx.get('fhc_personal_note')">
<p style="font-style:italic; color:#444;">
<t t-out="ctx.get('fhc_personal_note')"/>
</p>
</t>
<p>
Your team at <b><t t-out="object.x_fc_client_label or 'your deployment'"/></b>
has filed a request that needs your sign-off before
our team proceeds. A quick AI-prepared summary is
below; the full thread expands at the bottom if you
want the detail.
</p>
<div style="margin:14px 0; padding:12px 14px; background:#f9fafb; border:1px solid #e5e7eb; border-radius:6px;">
<div style="font-size:0.78rem; font-weight:700; text-transform:uppercase; letter-spacing:0.06em; color:#6c757d; margin-bottom:6px;">Summary</div>
<div style="white-space:pre-wrap; line-height:1.5;"><t t-out="object.x_fc_ai_summary or '(no AI summary available — see full thread below)'"/></div>
</div>
<div style="margin:18px 0;">
<div style="font-size:0.78rem; font-weight:700; text-transform:uppercase; letter-spacing:0.06em; color:#6c757d; margin-bottom:6px;">Request</div>
<div style="font-weight:600; font-size:1.02rem;"><t t-out="object.name"/></div>
</div>
<table cellpadding="0" cellspacing="0" style="margin:18px 0;">
<tr>
<td style="padding-right:8px;">
<a t-attf-href="{{ object.get_base_url() }}/fusion_helpdesk/engagement/{{ object.x_fc_engagement_token }}/approve"
target="_blank"
style="background:linear-gradient(135deg, #5cc66f 0%, #28a745 100%); padding:12px 22px; text-decoration:none; color:#ffffff; border-radius:6px; font-weight:700; font-size:14px; display:inline-block;">
✓ Approve
</a>
</td>
<td>
<a t-attf-href="{{ object.get_base_url() }}/fusion_helpdesk/engagement/{{ object.x_fc_engagement_token }}/reject"
target="_blank"
style="background:linear-gradient(135deg, #e85d68 0%, #dc3545 100%); padding:12px 22px; text-decoration:none; color:#ffffff; border-radius:6px; font-weight:700; font-size:14px; display:inline-block;">
✗ Reject
</a>
</td>
</tr>
</table>
<details style="margin:18px 0; color:#444; font-size:13px;">
<summary style="cursor:pointer; color:#2c89e9;">View original request &amp; full thread</summary>
<div style="margin-top:10px; padding:10px 14px; border-left:3px solid #d8dadd;">
<t t-out="object.description or ''"/>
</div>
</details>
<p style="color:#6c757d; font-size:12px; margin-top:24px;">
This Approve / Reject link is single-use and will
stop working once you've clicked it.
</p>
<p style="color:#6c757d; font-size:12px;">— Nexa Systems Support</p>
</div>
</field>
</record>
<!-- ============== BULK ENGAGEMENT ============== -->
<record id="mail_template_engagement_bulk" model="mail.template">
<field name="name">Helpdesk: Owner Approval Request (Bulk)</field>
<field name="model_id" ref="helpdesk.model_helpdesk_ticket"/>
<field name="subject">Action needed: {{ len(ctx.get('fhc_bulk_ticket_ids') or []) }} requests need your sign-off</field>
<field name="email_to">{{ object.x_fc_engagement_email }}</field>
<field name="reply_to">{{ (object.user_id.email or object.team_id.alias_email or object.company_id.email or '') }}</field>
<field name="lang">en_US</field>
<field name="auto_delete" eval="True"/>
<field name="body_html" type="html">
<div style="margin:0; padding:0; font-family:Arial, Helvetica, sans-serif; color:#21252b; font-size:14px;">
<p>Hi <t t-out="object.x_fc_engagement_name or 'there'"/>,</p>
<t t-if="ctx.get('fhc_personal_note')">
<p style="font-style:italic; color:#444;">
<t t-out="ctx.get('fhc_personal_note')"/>
</p>
</t>
<p>
<t t-out="len(ctx.get('fhc_bulk_ticket_ids') or [])"/>
requests from <b><t t-out="object.x_fc_client_label or 'your deployment'"/></b>
need your sign-off. Each can be approved or rejected
independently — clicking a button on one card only
acts on that card.
</p>
<t t-set="bulk_tickets" t-value="object.env['helpdesk.ticket'].browse(ctx.get('fhc_bulk_ticket_ids') or [])"/>
<t t-foreach="bulk_tickets" t-as="bt">
<div style="margin:18px 0; padding:14px 16px; background:#fff; border:1px solid #d8dadd; border-radius:8px;">
<div style="font-size:0.75rem; color:#6c757d; margin-bottom:6px;">Request <t t-out="bt_index + 1"/> of <t t-out="bt_size"/></div>
<div style="font-weight:600; font-size:1.02rem; margin-bottom:8px;"><t t-out="bt.name"/></div>
<div style="white-space:pre-wrap; line-height:1.5; background:#f9fafb; padding:10px 12px; border-radius:6px; border:1px solid #e5e7eb; font-size:0.92rem; margin-bottom:12px;">
<t t-out="bt.x_fc_ai_summary or '(no AI summary — open the full ticket via the team if needed)'"/>
</div>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="padding-right:8px;">
<a t-attf-href="{{ object.get_base_url() }}/fusion_helpdesk/engagement/{{ bt.x_fc_engagement_token }}/approve"
target="_blank"
style="background:linear-gradient(135deg, #5cc66f 0%, #28a745 100%); padding:10px 18px; text-decoration:none; color:#ffffff; border-radius:6px; font-weight:700; font-size:13px; display:inline-block;">
✓ Approve
</a>
</td>
<td>
<a t-attf-href="{{ object.get_base_url() }}/fusion_helpdesk/engagement/{{ bt.x_fc_engagement_token }}/reject"
target="_blank"
style="background:linear-gradient(135deg, #e85d68 0%, #dc3545 100%); padding:10px 18px; text-decoration:none; color:#ffffff; border-radius:6px; font-weight:700; font-size:13px; display:inline-block;">
✗ Reject
</a>
</td>
</tr>
</table>
</div>
</t>
<p style="color:#6c757d; font-size:12px; margin-top:24px;">
Each Approve / Reject link is single-use. Tap the
button on the card you want to decide on; the others
stay live in this email until you act on them or we
send a fresh request.
</p>
<p style="color:#6c757d; font-size:12px;">— Nexa Systems Support</p>
</div>
</field>
</record>
</data>
</odoo>