diff --git a/CLAUDE.md b/CLAUDE.md index 32e8f731..08aff26a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -134,3 +134,67 @@ PGPASSWORD='a09e12e0995dc29446631fa458f3d4b3' psql -h 100.74.28.73 -p 5433 -U po - `fusionapps.issues` — known issues and fixes - `fusionapps.code_snippets` — reference code - `fusionapps.quick_commands` — deployment and admin commands + +## Fusion Helpdesk — Customer Follow-up + Embedded Inbox (deployment + handoff) + +Two modules: **`fusion_helpdesk`** (client — runs on each client deployment, e.g. entech) +and **`fusion_helpdesk_central`** (runs on the central Odoo = nexa). The client forwards +tickets to central over **XML-RPC**; central find-or-creates the customer partner + +follower; the client shows a server-side-scoped "My Tickets" inbox + systray unread badge. + +### Where each runs / how to deploy +- **Central = nexa** (`erp.nexasystems.ca`, VM 315 on pve-worker1, Docker, DB `nexamain`). + Source on host: `/opt/odoo/custom-addons/fusion_helpdesk_central`. Upgrade (brief downtime): + ```bash + ssh pve-worker1 "qm guest exec 315 --timeout 590 -- bash -c 'docker stop odoo-nexa-app; docker run --rm --network odoo_odoo-network -v odoo_odoo-data:/var/lib/odoo -v /opt/odoo/custom-addons:/mnt/extra-addons -v /opt/odoo/enterprise-addons:/mnt/enterprise-addons -v /opt/odoo/odoo.conf:/etc/odoo/odoo.conf odoo-nexa:19 odoo -d nexamain -u fusion_helpdesk_central --stop-after-init --http-port=0 --gevent-port=0 > /tmp/up.log 2>&1; docker start odoo-nexa-app'" + ``` + Use `;` (not `&&`) before `docker start` so the app ALWAYS restarts even if the upgrade + fails. nexa `odoo.conf` has `log_level=warn`, so test/INFO lines are suppressed — verify + the result via DB query, not the upgrade log. +- **Client = entech** (LXC 111 on pve-worker5, **native systemd `odoo.service`**, DB `admin`, + config `/etc/odoo/odoo.conf`, source `/mnt/extra-addons/custom/fusion_helpdesk`). No host + bind mount — get files in with `scp` to pve-worker5 then `pct push 111 `. + Upgrade as the `odoo` user (NOT root): + ```bash + pct exec 111 -- bash -lc "systemctl stop odoo; runuser -u odoo -- /usr/bin/odoo --config /etc/odoo/odoo.conf -d admin -u fusion_helpdesk --stop-after-init --http-port=0 --gevent-port=0 --logfile=/tmp/up.log; systemctl start odoo" + ``` + **Backup dir MUST live OUTSIDE the addons path** (e.g. `/root/`). A dir named `*.bak.*` + *inside* `/mnt/extra-addons/custom` makes Odoo try to load it as a module → + `FileNotFoundError: Invalid module name: fusion_helpdesk.bak.predeploy` → whole registry + load fails. (Learned the hard way; auto-rollback restored it.) Current rollback copy: + `/root/fh_bak_predeploy`. + +### REQUIRED prerequisite on the central service account (easy to miss) +The keystone passes `partner_email`, so central find-or-creates the partner. The XML-RPC +service account (**`support@nexasystems.ca`, uid 33** on nexa) MUST have the **Contact +Creation** group (`base.group_partner_manager`). Without it, `helpdesk.ticket.create` +faults with *"not allowed to create 'Contact' (res.partner)"* for any reporter who isn't +already a contact. Granted on nexa 2026-05-27. **Every new client deployment needs this +grant on the central account.** + +### Testing lesson +Client logic (scope domain, seen model, vals, `_norm_email`) is unit-tested in +`fusion_helpdesk/tests/` and runs on local Community (`-d modsdev`). **Smoke tests must +call the controller endpoints, not re-implement their logic** — the Phase 6 smoke test +replicated `build_scope_domain` directly and so missed a `NameError` (`_norm_email` +referenced but never imported) that broke every inbox endpoint. Run +`docker exec odoo-modsdev-app python3 -m pyflakes ` after editing controllers — it +catches undefined names instantly. + +### STATUS (handoff 2026-05-27 — continuing from office) +- **Merged to `main`** as squash commit `6c15a7b1`, pushed to GitHub + Gitea. Feature + branch `feat/helpdesk-customer-followup` deleted (local + remote). Pull `main` at the + office to get the latest. +- **Deployed live**: nexa `fusion_helpdesk_central` **19.0.1.1.0**; entech `fusion_helpdesk` + **19.0.1.4.1**. Both services healthy. +- **Smoke-tested live end-to-end** (entech→nexa): partner resolved + follower + `ENTECH` + label, branded ack email queued, support reply visible in thread, inbox scope finds own + ticket, no cross-deployment leak. +- **Bug fixed this session**: `_norm_email` NameError that broke "My Tickets" AND the "New" + ticket submit path — `_norm_email` added to `fusion_helpdesk/utils.py`, imported in the + controller, regression test added, deployed to entech. +- **ONLY thing left = browser confirmation.** Hard-refresh entech (DevTools → Empty Cache + and Hard Reload), open the systray helpdesk dialog: **My Tickets** should load, and the + **New** tab should file a ticket. Both share the now-fixed `_identity()` path, and the + systray unread badge calls it too. If anything still errors, the traceback is in + `/var/log/odoo/odoo-server.log` on entech (LXC 111 / pve-worker5).