Files
Odoo-Modules/fusion_helpdesk_central/views/portal_templates.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

133 lines
7.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2026 Nexa Systems Inc.
License OPL-1
Minimal branded portal pages for the owner-approval flow. NOT using the
heavy portal.frontend_layout — the owner sees this once on their phone
and we want sub-200ms render, so each page is a self-contained HTML doc
with inline CSS. Branding kept consistent with the ack email's button
style (same blue, same border-radius).
-->
<odoo>
<!-- Shared shell: page wrapper, header strip, inline CSS reset. The
DOCTYPE is omitted — Odoo's QWeb XML parser rejects it inside
<template>, and modern browsers handle no-doctype pages fine for
a minimal confirmation page like this. Inline CSS keeps the
page self-contained, no external bundles to load. -->
<template id="engagement_layout" name="Owner Engagement Layout">
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Nexa Systems Support</title>
<style>
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; color: #21252b; background: #f3f4f6; -webkit-font-smoothing: antialiased; }
.fhc-header { background: #1e3a5f; color: #fff; padding: 14px 22px; font-weight: 700; letter-spacing: 0.02em; }
.fhc-card { max-width: 640px; margin: 28px auto; background: #fff; border: 1px solid #d8dadd; border-radius: 8px; padding: 22px 26px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.fhc-title { font-size: 1.15rem; font-weight: 700; margin: 0 0 6px 0; }
.fhc-meta { color: #6c757d; font-size: 0.85rem; margin-bottom: 14px; }
.fhc-section-h { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #6c757d; margin: 16px 0 6px 0; }
.fhc-summary { white-space: pre-wrap; line-height: 1.5; background: #f9fafb; padding: 12px 14px; border-radius: 6px; border: 1px solid #e5e7eb; font-size: 0.92rem; }
.fhc-comment { width: 100%; min-height: 90px; padding: 8px 10px; font-family: inherit; font-size: 0.95rem; border: 1px solid #d8dadd; border-radius: 6px; resize: vertical; }
.fhc-btn { display: inline-block; padding: 12px 26px; font-size: 1rem; font-weight: 700; border-radius: 6px; border: 0; color: #fff; cursor: pointer; }
.fhc-btn-approve { background: linear-gradient(135deg, #5cc66f 0%, #28a745 100%); }
.fhc-btn-reject { background: linear-gradient(135deg, #e85d68 0%, #dc3545 100%); }
.fhc-actions { display: flex; gap: 10px; margin-top: 14px; }
.fhc-foot { color: #9aa3ad; font-size: 0.78rem; text-align: center; margin-top: 18px; }
.fhc-bad { color: #b02a37; }
.fhc-good { color: #1e7e34; }
</style>
</head>
<body>
<div class="fhc-header">Nexa Systems Support</div>
<div class="fhc-card">
<t t-out="0"/>
</div>
<div class="fhc-foot">If this link doesn't look right, contact <a href="mailto:support@nexasystems.ca">support@nexasystems.ca</a>.</div>
</body>
</html>
</template>
<!-- Confirmation page: owner has clicked the magic link and we want
one last confirmation + optional comment before recording the
decision. POST goes back to the same URL. -->
<template id="engagement_confirm" name="Engagement Confirm">
<t t-call="fusion_helpdesk_central.engagement_layout">
<div class="fhc-title" t-esc="ticket.name"/>
<div class="fhc-meta">
Confirm your decision on this request — your name and any
comment below will be posted on the ticket so the team sees
it immediately.
</div>
<div class="fhc-section-h">Summary</div>
<div class="fhc-summary" t-esc="ticket.x_fc_ai_summary or 'No AI summary was attached to this request.'"/>
<form method="POST" action="">
<div class="fhc-section-h">Comment (optional)</div>
<textarea class="fhc-comment" name="comment"
placeholder="Add a note for the team (e.g. 'go ahead, this fits Q2 budget')"/>
<div class="fhc-actions">
<t t-if="decision_state == 'approved'">
<button class="fhc-btn fhc-btn-approve" type="submit">✓ Confirm Approval</button>
</t>
<t t-else="">
<button class="fhc-btn fhc-btn-reject" type="submit">✗ Confirm Rejection</button>
</t>
</div>
</form>
</t>
</template>
<!-- Done: decision recorded. Owner sees a friendly receipt. -->
<template id="engagement_done" name="Engagement Done">
<t t-call="fusion_helpdesk_central.engagement_layout">
<t t-if="decision_state == 'approved'">
<div class="fhc-title fhc-good">✓ Approval recorded</div>
</t>
<t t-else="">
<div class="fhc-title fhc-bad">✗ Rejection recorded</div>
</t>
<div class="fhc-meta">
Thanks — your decision on
"<b><t t-esc="ticket.name"/></b>"
has been posted to the ticket and the team has been notified.
You can safely close this tab. If you also received a bulk
email with multiple requests, come back to it and decide on
the others independently.
</div>
</t>
</template>
<!-- Invalid: token unknown, already used, or wrong state. -->
<template id="engagement_invalid" name="Engagement Invalid">
<t t-call="fusion_helpdesk_central.engagement_layout">
<div class="fhc-title fhc-bad">Link no longer valid</div>
<div class="fhc-meta">
This approval link has already been used, was replaced by a
newer request, or is otherwise no longer active.
If you think this is a mistake, please contact
<a href="mailto:support@nexasystems.ca">support@nexasystems.ca</a>
and we'll sort it out.
</div>
</t>
</template>
<!-- Server-side error -->
<template id="engagement_error" name="Engagement Error">
<t t-call="fusion_helpdesk_central.engagement_layout">
<div class="fhc-title fhc-bad">Something went wrong</div>
<div class="fhc-meta">
We couldn't record your decision because of an unexpected
error on our side. Please try the link again in a minute —
if it still fails, reply to the original email or contact
<a href="mailto:support@nexasystems.ca">support@nexasystems.ca</a>.
</div>
</t>
</template>
</odoo>