feat(fusion_repairs): Phase 1 sales rep + public client portals

Both portals share the existing fusion.repair.intake.service so behaviour
stays identical across all three intake surfaces (backend wizard,
sales rep portal, public client portal).

Sales rep portal
- Hard depends on fusion_authorizer_portal (reuses is_sales_rep_portal
  flag + group_sales_rep_portal scaffolding)
- /my/repair/new  - mobile-friendly intake form with phone-first
  partner search (jsonrpc lookup), category select, third-party flag,
  urgency, photo capture
- /my/repairs     - list of repairs the rep submitted (paginated)
- /my/repair/<id> - read-only detail with status, equipment, scheduled
  visit
- Interaction-class JS (Odoo 19 public.interactions), safe DOM construction
- Mobile SCSS with 44px tap targets, sticky CTA on small screens
- Record rule scopes portal users to repairs where
  x_fc_intake_user_id = user.id

Public client portal
- auth='public' - voicemail-ready /repair URL
- /repair         - landing page with 911 disclaimer and Start CTA
- /repair/new     - single-page form: contact, equipment, issue, urgency,
  optional photos. QR pre-fill via ?sn=<serial>
- /repair/submit  - CSRF + honeypot + per-IP rate limit (configurable);
  finds or creates partner; calls intake service with sudo
- /repair/thanks  - confirmation with reference number
- /repair/lookup_phone (jsonrpc) - safe partner match returning ONLY
  masked name (first + last initial) + city (no other PII leakage)

Security fix: technician record rule on repair.order now uses STORED
fields (technician_id + additional_technician_ids) instead of the
non-stored all_technician_ids compute, which was failing SQL generation.

Verified end-to-end on local westin-v19:
- Sales rep create via intake service with the rep user context creates
  the repair with x_fc_intake_source='sales_rep_portal' and proper
  activities
- /repair/submit posts urlencoded data -> creates partner + repair
  ('BR-WA/RO/00010', source='client_portal', urgency='urgent') ->
  redirects to /repair/thanks with the reference

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
gsinghpal
2026-05-20 21:52:12 -04:00
parent 429084e0bf
commit ad553b1082
11 changed files with 1105 additions and 3 deletions

View File

@@ -0,0 +1,107 @@
/** @odoo-module **/
// Sales rep portal - new service call form interactions.
// Uses Odoo 19 public Interaction class per project frontend rules
// (NOT IIFE / DOMContentLoaded). Uses only safe DOM construction
// (textContent + createElement) - no innerHTML, no XSS risk.
import { Interaction } from "@web/public/interaction";
import { registry } from "@web/core/registry";
import { rpc } from "@web/core/network/rpc";
export class SalesRepRepairIntake extends Interaction {
static selector = ".o_fusion_repairs_portal";
dynamicContent = {
"#partner_search": {
"t-on-input": this._onPartnerSearchInput,
},
};
setup() {
this._partnerSearchTimer = null;
}
_onPartnerSearchInput(ev) {
const query = (ev.target.value || "").trim();
if (this._partnerSearchTimer) {
clearTimeout(this._partnerSearchTimer);
}
if (query.length < 3) {
this._renderMatches([]);
return;
}
this._partnerSearchTimer = setTimeout(async () => {
try {
const result = await rpc("/my/repair/lookup_partner", { query });
this._renderMatches(result.matches || []);
} catch (e) {
this._renderMatches([]);
}
}, 250);
}
_renderMatches(matches) {
const list = document.getElementById("partner_matches");
if (!list) {
return;
}
while (list.firstChild) {
list.removeChild(list.firstChild);
}
for (const m of matches) {
list.appendChild(this._buildMatchItem(m));
}
}
_buildMatchItem(m) {
const item = document.createElement("button");
item.type = "button";
item.className = "list-group-item list-group-item-action text-start";
const nameStrong = document.createElement("strong");
nameStrong.textContent = m.name || "";
item.appendChild(nameStrong);
if (m.phone) {
const phone = document.createElement("span");
phone.className = "text-muted ms-2";
phone.textContent = m.phone;
item.appendChild(phone);
}
if (m.repair_count) {
const badge = document.createElement("span");
badge.className = "badge bg-secondary ms-2";
badge.textContent = `${m.repair_count} repair(s)`;
item.appendChild(badge);
}
if (m.street) {
const addr = document.createElement("div");
addr.className = "small text-muted";
addr.textContent = [m.street, m.city].filter(Boolean).join(", ");
item.appendChild(addr);
}
item.addEventListener("click", () => this._selectPartner(m));
return item;
}
_selectPartner(m) {
document.getElementById("partner_id_input").value = m.id;
document.getElementById("partner_selected_name").textContent =
m.name + (m.phone ? ` (${m.phone})` : "");
document
.getElementById("partner_selected")
.classList.remove("d-none");
const list = document.getElementById("partner_matches");
while (list.firstChild) {
list.removeChild(list.firstChild);
}
document.getElementById("partner_search").value = m.name;
}
}
registry
.category("public.interactions")
.add("fusion_repairs.sales_rep_intake", SalesRepRepairIntake);

View File

@@ -0,0 +1,39 @@
/* Public client portal - mobile-first.
* Follows project SCSS rules: no hardcoded theme colours, large tap targets,
* adapts to website light/dark theme automatically.
*/
.o_fusion_repairs_client {
.form-control,
.form-select,
.btn {
min-height: 44px;
}
.btn-lg {
min-height: 56px;
font-size: 1.125rem;
}
.card {
border-radius: 0.75rem;
}
h1.display-5,
h2 {
line-height: 1.2;
}
@media (max-width: 575px) {
section {
padding-top: 1.5rem !important;
padding-bottom: 1.5rem !important;
}
.card-footer {
position: sticky;
bottom: 0;
background: inherit;
z-index: 2;
}
}
}

View File

@@ -0,0 +1,39 @@
/* Sales rep portal - mobile-first additions.
* Follows project CLAUDE.md rules:
* - Tap targets >=44px
* - No hardcoded theme colours
* - Cards float on a slightly grayer page background
*/
.o_fusion_repairs_portal {
.card {
border-radius: 0.5rem;
}
.form-control,
.form-select,
.btn {
min-height: 44px;
}
.btn-lg {
min-height: 52px;
}
#partner_matches {
.list-group-item {
padding: 0.75rem 1rem;
cursor: pointer;
}
}
/* Sticky bottom CTA on small screens for the submit form. */
@media (max-width: 575px) {
.card-footer {
position: sticky;
bottom: 0;
background: inherit;
z-index: 2;
}
}
}