feat(plating): session 2026-05-23 deploys — F1/F7/S22/S23 + UI fixes
Consolidated commit of session work already deployed to entech and verified via the deep audit + the persona walk: S22 — Signoff gate (fp.job.step.requires_signoff was 100% unenforced, 42/42 done steps had NULL signoff_user_id). Three-piece fix: _fp_autosign_if_required (captures finisher on button_finish), _fp_check_signoff_complete (raises UserError if NULL after autosign), action_signoff (explicit supervisor pre-sign). Bypass: fp_skip_signoff_gate=True. S23 — Transition-form gate (same dormant-field shape as S22, caught preventively before recipe authors flipped requires_transition_form on). Model helpers on fp.job.step.move + controller gate in move_controller (parts commit) + pre-reject in rack commit. F7 — Chatter standardization: _fp_create_qc_check_if_needed, _fp_fire_notification, _fp_create_delivery silent failures now also post to job chatter instead of only logging to file. UI fixes: - Critical Rule 20 documented + applied: OWL templates only expose Math as a global. Calling String(d) inside t-on-click throws 'v2 is not a function'. Fixed pin_pad.xml (string array instead of number array with String() coercion). Also swept parseInt/ parseFloat in recipe_tree_editor + simple_recipe_editor. - Notes panel HTML escape fix: chatter messages off /fp/workspace/load were rendered via t-out, escaping the HTML. Wrap with markup() in job_workspace.js refresh() before assigning to state. Versions: fusion_plating 19.0.20.8.0 → 19.0.20.9.0 fusion_plating_jobs 19.0.10.20.0 → 19.0.10.23.0 fusion_plating_shopfloor 19.0.30.2.0 → 19.0.30.5.0 All deployed to entech (LXC 111) and verified live. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -228,6 +228,8 @@ Use only: `name`, `model_id`, `state`, `code` (or `function`/`model`), `interval
|
||||
Both are test-data scaffolding; neither weakens assertions and neither must appear in production code paths.
|
||||
18. **Portal list pages — no pagination, 500-record cap**: All FP portal list routes (quote requests, jobs, certifications, deliveries) load up to 500 records and rely on client-side JS filtering. Do NOT re-add `portal_pager` to these routes. The `fp_portal_list_controls` macro + `fp_portal_list_search.js` handle filtering, counting, and the sort dropdown. Hidden `<td class="d-none">` cells inside each row carry extra searchable text (part number, customer PO, contact) that isn't displayed but is matched by the JS.
|
||||
19. **QWeb `t-value` is Python, not Jinja**: `t-value="orders|length"` does NOT call a filter — Python parses `|` as bitwise/recordset OR, so on a non-empty recordset it tries `recordset | length_var` and raises `TypeError: unsupported operand types in: sale.order(…) | None` (when `length` is undefined) or returns a merged recordset (when `length` happens to be another recordset). Use `len(orders)` or `bool(orders)` or `(orders and orders[0]) or False` — explicit Python. Same trap applies to `|default`, `|first`, `|join`, etc. — none of these Jinja filters exist in QWeb. Bit us 2026-05-18 on `fp_sale_order_portal.xml` injecting `result_total` into the list-controls macro.
|
||||
20. **OWL templates expose `Math` but NOT `String` / `Number` / `Array` / `Object` / `Boolean` / `JSON` / `parseInt` / `parseFloat`**: writing `t-on-click="() => this._press(String(d))"` (or similar coercion inside any template expression) throws `Uncaught TypeError: v2 is not a function` at click time — `v2` is OWL's compiled reference to a global that doesn't exist in template scope. The click handler dies before its body runs, so the bug looks like "nothing happens when I press" (no error in the UI, only DevTools shows the trace). **Fixes, in order of preference**: (a) eliminate the coercion entirely — store data in the right type up front, e.g. `t-foreach="['1','2','3']"` instead of `[1,2,3]` so `d` is already a string. (b) Use a JS-side coercion: pass the raw value to the handler and call `String(digit)` inside the component method. (c) Use a pure-expression workaround like string concatenation: `'' + d` does work because `+` is an operator, not a function. **Do NOT try to monkey-patch `String` onto the component (e.g. `this.String = String`) or onto `env` — leaks the global into every component and is fragile across OWL upgrades.** Bit us 2026-05-23 on `pin_pad.xml` — operators couldn't tap PIN digits at all because the click handler died on `String(d)`; the SCSS, reactivity, and `_press` method were all fine, the template scope was the entire bug. Same trap applies to OWL templates anywhere in the codebase: `move_parts_dialog.xml`, `manager_dashboard.xml`, `fp_record_inputs_dialog.xml`, etc. — grep all `t-on-click`, `t-att-*`, and `t-out` expressions for `String(`, `Number(`, `Array(`, `parseInt(`, `parseFloat(`, `JSON.` before merging.
|
||||
21. **`ir.actions.act_window_close` is a no-op when the current action was opened with `target: "current"`**: replacing the current action wipes the breadcrumb backstack, so there's nothing to close back to. The user clicks "Back" and nothing happens (no error, no navigation). This bites every OWL client-action surface that calls another client action via `doAction({..., target: "current"})` — the destination has no way to return to the source. **Fix pattern for "Back" buttons in OWL client actions**: navigate EXPLICITLY to the landing/parent action by tag, e.g. `this.action.doAction({ type: "ir.actions.client", tag: "fp_shopfloor_landing", target: "current" })` — works regardless of how the action was reached (kanban tap, QR scan, smart button, direct URL). **Do NOT rely on `act_window_close`, `history.back()`, or `this.env.config.breadcrumbs`** — all three are unreliable across navigation paths. Bit us 2026-05-23 on the Job Workspace Back button after the kanban opened the workspace with `target: "current"`. The same pattern applies to every other "Back" button in shopfloor / manager / portal OWL surfaces — explicit destination via `tag:` is the only robust answer.
|
||||
|
||||
## Naming
|
||||
- **New custom models** (post-2026-04): `fp.*` prefix (e.g. `fp.part.catalog`, `fp.certificate`)
|
||||
@@ -1132,6 +1134,9 @@ Each script is self-contained — builds a fresh SO + job, walks the scenario, a
|
||||
| **S19** | Lisa uploads Fischerscope X-Ray thickness PDF to QC; CoC ships without it as page 2 — and even after the back-end merge worked, operators couldn't *see* in the cert form whether the merge would happen | Existing merge logic lived in uninstalled `fusion_plating_bridge_mrp` (keyed off `mrp.production` — gone with Sub 11). Post-Sub-11 cert path rendered CoC only; Fischerscope PDF stayed orphaned on the QC record. Even after Phase 1 fix shipped, the cert form had **zero** indicator that a thickness PDF was on file or had been merged → user reported "I did not see anything in the certification issue" | **Phase 1 (back-end merge):** Ported merge to `fp.certificate._fp_merge_thickness_into_pdf`. New `_fp_render_and_attach_pdf` wraps cert PDF generation: renders the CoC via QWeb, then looks up the linked `fusion.plating.quality.check` (`x_fc_job_id → fp.job → QC`), finds the most recent passed QC with `thickness_report_pdf_id`, merges via `pypdf.PdfWriter.append()` (PyPDF2 `PdfMerger` fallback), posts chatter audit `Fischerscope thickness report from QC <name> appended to CoC PDF.`. Hooked into `action_issue` so the multi-page PDF lands on `attachment_id` automatically. **Phase 2 (UI surface):** Added 3 computed fields on `fp.certificate` (in `fusion_plating_jobs`): `x_fc_thickness_qc_id` (linked QC), `x_fc_thickness_pdf_id` (Fischerscope PDF), `x_fc_thickness_status` (`none` / `pending` / `merged`). Cert form now shows: (1) coloured banner above the title — blue "Will Append on Issue" / green "Merged" / amber "No PDF — operator action required"; (2) two new smart buttons (Plating Job, Fischerscope status); (3) new "Thickness Report (Fischerscope)" notebook tab with clickable PDF preview + step-by-step instructions when none uploaded | `fusion_plating_certificates 19.0.5.2.0`, `fusion_plating_jobs 19.0.6.20.0` | `bt_s19_fischer_merge.py` (asserts both pre-Issue `pending` + post-Issue `merged` status flips) |
|
||||
| **S20** | Tablet Station UX hardening — three real-world UX gaps surfaced during a persona walk on the Tablet + Manager Desk client actions | (a) **Scrap reason dropped**: `/fp/shopfloor/bump_qty_scrapped` accepted operator's typed reason via `window.prompt`, passed it through context as `fp_scrap_reason` — but `fp.job.write` never read it, so the auto-spawned Hold's description had the generic "OPERATOR: replace this text with the actual reason" placeholder instead of what Carlos typed. Audit trail lost what just happened on the floor. (b) **KPI/panel mismatch**: tablet KPI strip showed plant-wide totals ("Quality Holds: 12") but the Holds panel below was scoped to the operator's own jobs (might show 0). Operator stares at a big red 12, scrolls down, sees nothing — confused/distrustful. (c) **UserError stack-trace leak**: when `start_wo` hit an S14 predecessor lock (or any other `button_start`-side guard), the raw `UserError` propagated through the JSON-RPC handler and operator got a Python stack-trace dialog instead of the nice `setMessage("...", "danger")` flash. Same hole on `stop_wo`, `start_bake`, `end_bake`, `mark_gate`, `bump_qty_done`, `bump_qty_scrapped`. | (a) `fp.job.write` now reads `self.env.context.get('fp_scrap_reason')` and prepends `Operator reason: <text>` to the Hold description so the audit row captures what the operator actually typed. (b) Tablet KPI strip now reuses `my_job_ids_for_kpi` (the operator's own steps) for `awaiting_bakes`, `bake_in_progress`, `missed`, `open_holds` — same scope as the panels below, so the strip never lies. Manager dashboard keeps its own plant-wide KPI set. (c) Wrapped every action endpoint in `try: ... except UserError as e: return {'ok': False, 'error': str(e.args[0])}` — operator now gets the clean `setMessage` flash with the real guard text ("Step 'X' requires predecessors done first…") instead of a stack-trace popup. | `fusion_plating_jobs 19.0.6.22.0`, `fusion_plating_shopfloor 19.0.24.4.0` | persona walk via `sim_tablet_actions.py` + `sim_reverify.py` (asserts: typed reason ends up in hold.description, KPI=panel for holds, `start_wo` returns `{ok:False, error:"..."}` for locked step) |
|
||||
| **S20** | **Tablet usability pass** — operators were squinting at the tablet, scanning back-and-forth between recipe binders and the screen because the tablet showed step names but no targets, no live timer, no predecessor visibility. QC fail left parts in limbo with no Hold record. Manager Desk showed feel-good KPIs but hid the compliance bombs (missed bakes, stale steps, locked steps, holds, pending QC missing PDF) | Tablet `My Queue` rows had no `instructions`, `thickness_target`, `dwell_time_minutes`, `bake_setpoint_temp`, `requires_signoff` — operators kept scanning the QR code just to read the bake temperature. Steps with `requires_predecessor_done=True` (S14) showed a green Start that always failed with a UserError. Active step "duration" was a stale number that only refreshed every 30s. Holds and bake windows showed plant-wide noise from other crews. **No banner alerted Carlos when his job had a pending QC** (Lisa was not called → QC sat for hours). **No way to bump qty_done or scrap from the tablet** → S17 hold auto-spawn never fired because operators didn't update the field. **`action_fail` on QC marked the check failed but spawned no Hold** — AS9100 disposition trail broken. **Manager Desk KPIs were missing 7 compliance metrics**: stale paused/in-progress steps (cron data), missed bake windows, open holds, predecessor-locked steps, pending QCs, QCs missing Fischerscope PDF, draft cert pipeline | **Carlos's Shopfloor Tablet** — every queue row now carries the recipe-author fields (instructions snippet, thickness target chip, dwell-time chip, bake-temp chip, sign-off badge) so operators read the targets inline. Predecessor-blocked steps render with a 🔒 lock icon, an "Awaiting [step name]" notice, and a disabled `Locked` button (no more Start-then-fail). Active step now shows a **live ticking HH:MM:SS clock** (1s interval, computed from `date_started_iso` JS-side; flips to red on >1.5× planned duration) plus `+1 Done` and `Scrap` buttons that hit two new endpoints (`/fp/shopfloor/bump_qty_done`, `/fp/shopfloor/bump_qty_scrapped` — scrap prompts for reason and S17 auto-spawns the Hold). New **Pending QC banner** lists open QCs for my jobs with line-progress + Fischerscope-PDF status badge, and a tap deep-links into Lisa's mobile QC checklist. Holds and bake windows are now **scoped to my jobs first** (fall back to facility-wide for managers). **QC checklist** — `action_fail` now auto-creates a `fusion.plating.quality.hold` with `hold_reason='qc_failure'` (new selection value), populated description listing the failed checks, idempotent on retry. **Manager Desk** — 7 new clickable compliance KPI tiles: Missed Bakes (S15), Open Holds (S17 + QC fail), Stale Steps (S10/S16 cron data), Locked Steps (S14), Pending QC + "X need PDF" (S19 + missing-Fischerscope), Draft Certs + "Y today" (cert pipeline). Each tile drills into a list filtered to the relevant exception | `fusion_plating_shopfloor 19.0.24.3.0`, `fusion_plating_quality 19.0.4.8.0` | `sim_tablet_walk.py`, `sim_timer_pred_test.py`, `sim_qc_fail_hold.py`, `sim_manager_qc_fail.py` (one-off persona walkthroughs) |
|
||||
| **S21** | Riya finished steps on WO-30051 without filling in mandatory recipe-author prompts — Incoming Inspection skipped "Take and Upload Photos" (1/5 missed), Check Sulfamate Nickel Area skipped both masking-verification booleans (2/3 missed). AS9100 audit trail broken on a per-step basis. | (a) `_fp_has_uncaptured_step_inputs` returned False as soon as ANY move with input values existed since `date_started` — too coarse, let operators clear the dialog re-open by saving a single prompt. (b) `button_finish` had NO gate enforcing required step_input coverage — only Contract Review + Receiving gates fired. (c) OWL `Record Inputs` dialog `onSave()` had no client-side check for required prompts either, so operators got zero feedback when leaving fields blank. (d) Also caught: `fp_job_step.py` had **two `def button_finish` in the same class** — Python silently kept only the second definition, so the bake.window auto-spawn + duration-overrun warning at line 596 had been dead code for the entire WO-30051 era. | **Server gate** — new `_fp_check_step_inputs_complete()` on `fp.job.step` raises `UserError` listing every missing required step_input by name. Hooked into `button_finish` ahead of the existing Contract Review + Receiving gates. New helper `_fp_missing_required_step_inputs()` returns the recordset of required prompts with NO recorded value across any move from this step (centralised — used by both the gate and the dialog re-open helper). `_fp_has_uncaptured_step_inputs()` tightened to delegate to the new helper. **Client gate** — `onSave()` on `FpRecordInputsDialog` mirrors the server check when `advanceAfter=true` (Finish & Next path) so operators see a sticky red "Cannot finish step — N required prompts missing: ..." notification instantly rather than after a server roundtrip. Partial saves via the per-row Record button (`advanceAfter=false`) remain unblocked — operators can still capture progress and come back to fill the rest. **Manager bypass** — `fp_skip_required_inputs_gate=True` (documented deviations / paper-form catch-up); posts chatter audit naming the user. **Dead-code merge** — the duplicate `button_finish` at line 596 was deleted; its bake.window auto-spawn + duration-overrun chatter logic was folded into the canonical `button_finish` (which now runs in order: required-inputs gate → CR gate → receiving gate → `super()` → post-finish side effects). **Critical lesson — never put two `def <name>` in the same `models.Model` class body**. Python silently keeps the last one; the earlier definition becomes dead code with no warning. Always grep for duplicates after any structural edit on a long model file. | `fusion_plating_jobs 19.0.10.22.0` | Smoke: `step._fp_missing_required_step_inputs()` on any in_progress step returns the prompt recordset that would block finish. Server: try `step.button_finish()` on a step with required prompts unrecorded — should raise UserError listing them. Manager bypass: `step.with_context(fp_skip_required_inputs_gate=True).button_finish()` succeeds + posts audit. |
|
||||
| **S22** | Deep-audit finding F1 (2026-05-23) — `fp.job.step.requires_signoff` was 100% unenforced on entech: 42 of 42 done steps with the field set had `signoff_user_id IS NULL`. Recipe authors believed they'd gated aerospace / Nadcap steps; reality was the field was decorative. Pre-Sub-11 the `mrp.workorder.x_fc_signoff_user_id` had working logic, but Sub 11's MRP cutout removed bridge_mrp without porting the gate. | `signoff_user_id` was defined `readonly=True` on `fp.job.step` (from `fusion_plating/models/fp_job_step.py`) but **no code anywhere wrote to it**. No autosign on finish, no UI button, no `action_signoff`. Deep audit caught this because the 42/42 = 100% NULL ratio is the dead giveaway — when a "required" field has zero non-NULL rows across 42 records, the field's enforcement code is missing entirely. | **Three-piece fix on `fp.job.step`**: (1) `_fp_autosign_if_required()` — auto-sets `signoff_user_id = env.user.id` for the user clicking Finish, idempotent (preserves a supervisor's pre-sign via `action_signoff`). (2) `_fp_check_signoff_complete()` — raises `UserError` when `requires_signoff=True` and `signoff_user_id` is still NULL after the autosign helper has run (i.e. migration scripts, background crons with no env.user). (3) `action_signoff()` — explicit sign-off action for the case where a supervisor reviews and signs BEFORE the operator clicks Finish. Same-user re-click is a no-op; a DIFFERENT user re-signing overwrites the prior signer and posts a chatter reassignment ("Sign-off on step X reassigned from A to B"). Both helpers hook into `button_finish` AFTER `_fp_check_step_inputs_complete` and BEFORE the Contract-Review gate. **Manager bypass** — `fp_skip_signoff_gate=True` (documented deviations); posts chatter naming the user. **Lesson — for ANY "required" Boolean field that gates downstream behaviour, ALWAYS deep-audit the enforcement path: search the codebase for writes to the gated field, not just the boolean.** If zero writes exist, the gate is structural / decorative only. Grep the codebase periodically for `_check_*` helpers whose triggering field has no inverse writer. | `fusion_plating_jobs 19.0.10.23.0` | Verified end-to-end on entech: autosign sets signoff_user_id, gate raises UserError with the right message, bypass posts chatter audit, action_signoff sets + posts chatter, and the S21 required-inputs gate still fires (no regression). |
|
||||
| **S23 (shipped)** | Deep-audit bonus finding (2026-05-23) — `fp.job.step.requires_transition_form` had the same dormant-field shape as S22's signoff bug. The bypass context flag `fp_skip_transition_form` was already wired into the move controller's audit trail, but **no actual gate ever fired** because `_blockers_for_move` only enumerated `rack_required` + `predecessor_lock`. 0 of 286 moves on entech had this set (recipe authors hadn't enabled it), so no current audit gap — but the next recipe author who flips the toggle would discover the same cosmetic-only behaviour Riya found on S21. Caught preventively rather than reactively. NB: numbering conflicts with the open-scenarios list (also lists S23) — accept; the open list will be renumbered in a future doc-cleanup pass. | (a) `_blockers_for_move` in `fusion_plating_shopfloor/controllers/move_controller.py` had no `transition_form_required` case, only rack + predecessor. (b) The Move Rack controller `_do_move_rack_commit` didn't capture transition prompts at all — even if `requires_transition_form` were enforced on Move Parts, rack moves silently bypassed it. (c) The model layer `fp.job.step.move` had no helper to compute "missing required transition inputs", so any backend caller (wizards, scripts) had no way to enforce the contract. | **Model layer** — added two helpers to `fp.job.step.move` (canonical location): `_fp_missing_required_transition_inputs()` returns the recordset of required transition_input prompts on `to_step.recipe_node_id` that have no captured value on the move. `_fp_check_transition_inputs_complete()` raises `UserError` listing the missing prompts, manager bypass via `fp_skip_transition_form=True` (consistent with the existing audit-trail flag, NOT a new flag name), posts chatter on the move record on bypass. **Controller wiring** — `move_parts_commit` calls the gate AFTER `_capture_prompt_value` (so the operator gets credit for whatever they filled in; rollback unwinds the move + values on failure). `move_rack_commit` pre-rejects with a clear message ("use Move Parts so the form can be filled in") because rack moves have no per-batch prompt-capture UI. **Design choice** — gate is invoked explicitly by callers rather than via `create()` override; values are written in a separate call after the move row, so a model-level `create()` hook would always misfire. Future backend wizards / scripts MUST call `_fp_check_transition_inputs_complete()` after capturing prompt values, or pass `fp_skip_transition_form=True` if intentionally bypassing. **Two-layer pattern lesson** — when a recipe-author flag (here `requires_transition_form`) has BOTH a quick path (Move Rack — no form UI) AND a rich path (Move Parts — full form UI), the quick path MUST either implement the form OR reject the operation. A silent quick-path bypass defeats the whole gate. | `fusion_plating 19.0.20.9.0`, `fusion_plating_shopfloor 19.0.30.3.0` | Verified live on entech: helpers callable, move-parts commit raises on missing required prompts, move-rack commit rejects up-front when `to_step.requires_transition_form=True`, manager bypass via context flag posts move-chatter audit. |
|
||||
|
||||
### Manager-bypass context flags
|
||||
|
||||
@@ -1145,6 +1150,9 @@ When you need to override a guard (documented customer deviation, emergency rewo
|
||||
| `fp_skip_bake_gate=True` | bake.window pending check on `button_mark_done` (S15) |
|
||||
| `fp_skip_predecessor_check=True` | requires_predecessor_done check on `button_start` (S14) |
|
||||
| `fp_skip_missed_window=True` | missed_window block on `bake.window.action_start_bake` (S6) |
|
||||
| `fp_skip_required_inputs_gate=True` | required step_input prompts check on `fp.job.step.button_finish` (S21). Posts chatter audit naming the user. |
|
||||
| `fp_skip_signoff_gate=True` | `requires_signoff` + `signoff_user_id` check on `fp.job.step.button_finish` (S22). Posts chatter audit naming the user. Note: button_finish auto-sets signoff_user_id to the finisher first (via `_fp_autosign_if_required`); this bypass only matters when even the autosign can't fire (migration scripts, background crons with no env.user). |
|
||||
| `fp_skip_transition_form=True` | `requires_transition_form` + required transition_input coverage check on `fp.job.step.move._fp_check_transition_inputs_complete` (S23). Also drops the existing rack-vs-transition-form pre-reject on `move_rack_commit`. Posts chatter audit on the move record. Manager-only — controller checks the `fusion_plating.group_fusion_plating_manager` membership before honoring the flag. |
|
||||
|
||||
### Daily / hourly crons added by battle tests
|
||||
|
||||
@@ -1156,13 +1164,13 @@ When you need to override a guard (documented customer deviation, emergency rewo
|
||||
|
||||
### Open scenarios — flagged for next session
|
||||
|
||||
- **S21** — Operator clocks two steps simultaneously across different jobs (multi-tasking conflict)
|
||||
- **S22** — Bath chemistry drift mid-step — operator measures bath while plating, value out of spec; no alert on the step
|
||||
- **S23** — Wrong recipe attached — Carlos sees mismatch with the part he's holding; recovery path?
|
||||
- **S24** — Customer orders 100 parts spread across 3 jobs; one job's recipe gets edited — does it propagate to siblings?
|
||||
- **S25** — Hold-aging cron + 3-day escalation (flagged in original audit, not yet built)
|
||||
- **S26** — Calibration + permit-expiry cron (flagged in original audit, not yet built)
|
||||
- **S27** — FAIR detection on first-shipment to a new customer/part combo (flagged in original audit, not yet built)
|
||||
- **S23** — Bath chemistry drift mid-step — operator measures bath while plating, value out of spec; no alert on the step (renumbered from S22 when S22 was claimed for the signoff gate)
|
||||
- **S24** — Wrong recipe attached — Carlos sees mismatch with the part he's holding; recovery path?
|
||||
- **S25** — Customer orders 100 parts spread across 3 jobs; one job's recipe gets edited — does it propagate to siblings?
|
||||
- **S26** — Hold-aging cron + 3-day escalation (flagged in original audit, not yet built)
|
||||
- **S27** — Calibration + permit-expiry cron (flagged in original audit, not yet built)
|
||||
- **S28** — FAIR detection on first-shipment to a new customer/part combo (flagged in original audit, not yet built)
|
||||
- **S29** — Operator clocks two steps simultaneously across different jobs (multi-tasking conflict; renumbered from S21 → S28 → S29)
|
||||
|
||||
### Tablet UI / persona-coverage gaps (S20 audit follow-ups)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
'name': 'Fusion Plating',
|
||||
'version': '19.0.20.8.0',
|
||||
'version': '19.0.20.10.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Core plating / metal finishing ERP: facilities, processes, tanks, baths, jobs, operators.',
|
||||
'description': """
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
from odoo import api, fields, models
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class FpJobStepMove(models.Model):
|
||||
@@ -74,6 +77,92 @@ class FpJobStepMove(models.Model):
|
||||
string='Transition Input Values',
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# S23 — required transition-input gate
|
||||
# ------------------------------------------------------------------
|
||||
# When the destination step has requires_transition_form=True, the
|
||||
# recipe author wants chain-of-custody attestations captured on the
|
||||
# move (location, photo, customer WO #, etc.). Same dormant-field
|
||||
# shape as S22's signoff bug — the field existed but nothing enforced
|
||||
# it. Callers (tablet controllers, future backend wizards) MUST call
|
||||
# _fp_check_transition_inputs_complete() after writing values to
|
||||
# transition_input_value_ids.
|
||||
#
|
||||
# We can't gate on create() because values are written in a separate
|
||||
# call after the move row. Model-level enforcement would require
|
||||
# either a deferred-commit pattern or a write hook; explicit caller
|
||||
# invocation is the simplest contract.
|
||||
|
||||
def _fp_missing_required_transition_inputs(self):
|
||||
"""Return the recordset of required transition_input prompts on
|
||||
the to_step's recipe node that have NO captured value on this
|
||||
move. Centralised helper — used by the gate below and by future
|
||||
diagnostics."""
|
||||
self.ensure_one()
|
||||
Prompt = self.env['fusion.plating.process.node.input']
|
||||
to_step = self.to_step_id
|
||||
if not to_step or not to_step.recipe_node_id:
|
||||
return Prompt
|
||||
if not to_step.requires_transition_form:
|
||||
return Prompt
|
||||
prompts = to_step.recipe_node_id.input_ids
|
||||
if 'kind' in prompts._fields:
|
||||
prompts = prompts.filtered(
|
||||
lambda i: i.kind == 'transition_input')
|
||||
if 'collect' in prompts._fields:
|
||||
prompts = prompts.filtered(lambda i: i.collect)
|
||||
required_prompts = prompts.filtered(lambda i: i.required)
|
||||
if not required_prompts:
|
||||
return Prompt
|
||||
recorded_input_ids = set(
|
||||
self.transition_input_value_ids.mapped('node_input_id.id')
|
||||
)
|
||||
return required_prompts.filtered(
|
||||
lambda p: p.id not in recorded_input_ids
|
||||
)
|
||||
|
||||
def _fp_check_transition_inputs_complete(self):
|
||||
"""Raise UserError when the destination step has
|
||||
requires_transition_form=True and required transition_input
|
||||
prompts haven't been recorded on this move. Audit gate — same
|
||||
shape as fp.job.step._fp_check_step_inputs_complete (S21) and
|
||||
._fp_check_signoff_complete (S22).
|
||||
|
||||
Manager bypass via context fp_skip_transition_form=True
|
||||
(consistent with the existing audit-trail flag on the tablet
|
||||
controllers). Bypasses are posted to chatter on the move
|
||||
record naming the user.
|
||||
"""
|
||||
if self.env.context.get('fp_skip_transition_form'):
|
||||
for move in self:
|
||||
if not move.to_step_id.requires_transition_form:
|
||||
continue
|
||||
move.message_post(body=Markup(_(
|
||||
'Transition-form gate bypassed by %s. '
|
||||
'Documented deviation — required prompts not '
|
||||
'recorded on this move.'
|
||||
)) % self.env.user.name)
|
||||
return
|
||||
for move in self:
|
||||
missing = move._fp_missing_required_transition_inputs()
|
||||
if not missing:
|
||||
continue
|
||||
names = ', '.join(
|
||||
'"%s"' % (p.name or '').strip() for p in missing
|
||||
)
|
||||
raise UserError(_(
|
||||
'Move to step "%(step)s" cannot be committed — '
|
||||
'%(n)s required transition prompt(s) not recorded: '
|
||||
'%(names)s. Fill them in the Move dialog before '
|
||||
'committing. Managers can override via context flag '
|
||||
'fp_skip_transition_form=True for documented '
|
||||
'deviations.'
|
||||
) % {
|
||||
'step': move.to_step_id.name,
|
||||
'n': len(missing),
|
||||
'names': names,
|
||||
})
|
||||
|
||||
|
||||
class FpJobStepMoveInputValue(models.Model):
|
||||
"""Captured value for one transition-input prompt.
|
||||
|
||||
@@ -321,7 +321,7 @@
|
||||
<label>Estimated Duration (min)</label>
|
||||
<input type="number" class="form-control" min="0" step="1"
|
||||
t-att-value="state.selectedNode.estimated_duration || 0"
|
||||
t-on-change="(ev) => { state.selectedNode.estimated_duration = parseFloat(ev.target.value) || 0; }"/>
|
||||
t-on-change="(ev) => { state.selectedNode.estimated_duration = (+ev.target.value) || 0; }"/>
|
||||
</div>
|
||||
|
||||
<div class="o_fp_re_field">
|
||||
@@ -380,7 +380,7 @@
|
||||
<label for="fp_re_workflow_state">Triggers Workflow State</label>
|
||||
<select id="fp_re_workflow_state"
|
||||
class="form-select"
|
||||
t-on-change="(ev) => { state.selectedNode.triggers_workflow_state_id = ev.target.value ? parseInt(ev.target.value, 10) : false; }">
|
||||
t-on-change="(ev) => { state.selectedNode.triggers_workflow_state_id = ev.target.value ? (+ev.target.value) : false; }">
|
||||
<option value=""
|
||||
t-att-selected="!state.selectedNode.triggers_workflow_state_id">
|
||||
— None (use default-kind matching) —
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
t-if="state.workflowStates and state.workflowStates.length">
|
||||
<label>Triggers Workflow State</label>
|
||||
<select class="form-select"
|
||||
t-on-change="(ev) => { state.editTriggersWorkflowStateId = ev.target.value ? parseInt(ev.target.value, 10) : false; }">
|
||||
t-on-change="(ev) => { state.editTriggersWorkflowStateId = ev.target.value ? (+ev.target.value) : false; }">
|
||||
<option value="" t-att-selected="!state.editTriggersWorkflowStateId">— None (use Step Type) —</option>
|
||||
<t t-foreach="state.workflowStates" t-as="ws" t-key="ws.id">
|
||||
<option t-att-value="ws.id"
|
||||
@@ -598,7 +598,7 @@
|
||||
t-if="state.workflowStates and state.workflowStates.length">
|
||||
<label class="form-label">Triggers Workflow State</label>
|
||||
<select class="form-select"
|
||||
t-on-change="(ev) => { state.libraryEditor.triggers_workflow_state_id = ev.target.value ? parseInt(ev.target.value, 10) : false; }">
|
||||
t-on-change="(ev) => { state.libraryEditor.triggers_workflow_state_id = ev.target.value ? (+ev.target.value) : false; }">
|
||||
<option value=""
|
||||
t-att-selected="!state.libraryEditor.triggers_workflow_state_id">
|
||||
— None (use default-kind matching) —
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
{
|
||||
'name': 'Fusion Plating — Native Jobs',
|
||||
'version': '19.0.10.20.0',
|
||||
'version': '19.0.10.23.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Native plating job model — replaces mrp.production / mrp.workorder bridge.',
|
||||
'author': 'Nexa Systems Inc.',
|
||||
|
||||
@@ -1485,25 +1485,26 @@ class FpJob(models.Model):
|
||||
def _fp_create_portal_job(self):
|
||||
"""Create the fusion.plating.portal.job mirror record.
|
||||
|
||||
Initial state derived from the fp.job state via the same map
|
||||
used by write() — so a job that's already 'in_progress' when
|
||||
the portal mirror is created (e.g. a manual catch-up create)
|
||||
doesn't reset to 'received'.
|
||||
Seeded with 'received' then handed to
|
||||
`fusion.plating.portal.job._fp_recompute_portal_state` — that
|
||||
helper is the single source of truth for portal state and
|
||||
derives it from the WO + shipment + invoice signals, so a
|
||||
catch-up create on an already-in-progress job lands on the
|
||||
right state rather than stuck on 'received'.
|
||||
"""
|
||||
self.ensure_one()
|
||||
if self.portal_job_id:
|
||||
return # already exists — idempotent
|
||||
Portal = self.env['fusion.plating.portal.job'].sudo()
|
||||
initial_state = self._FP_JOB_STATE_TO_PORTAL_STATE.get(
|
||||
self.state, 'received',
|
||||
)
|
||||
portal = Portal.create({
|
||||
'name': self.name,
|
||||
'partner_id': self.partner_id.id,
|
||||
'state': initial_state,
|
||||
'state': 'received',
|
||||
'x_fc_job_id': self.id,
|
||||
})
|
||||
self.portal_job_id = portal.id
|
||||
if hasattr(portal, '_fp_recompute_portal_state'):
|
||||
portal._fp_recompute_portal_state()
|
||||
|
||||
def _fp_create_qc_check_if_needed(self):
|
||||
"""If customer has x_fc_requires_qc=True, spawn a QC check via
|
||||
@@ -1528,9 +1529,17 @@ class FpJob(models.Model):
|
||||
try:
|
||||
QC.create_for_job(self)
|
||||
except Exception as e:
|
||||
# F7 — surface silent failures on the job's chatter so the
|
||||
# operator sees the gap and creates the QC manually. Logging
|
||||
# to /var/log/odoo/odoo-server.log alone meant nobody noticed
|
||||
# (2CM's WH/JOB/00002 silently lost its QC check this way).
|
||||
_logger.warning(
|
||||
"Job %s: create_for_job failed: %s", self.name, e,
|
||||
)
|
||||
self.message_post(body=_(
|
||||
'QC check auto-create failed: %(e)s. '
|
||||
'Create the QC check manually from the Quality menu.'
|
||||
) % {'e': e})
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# button_mark_done — Task 2.8
|
||||
@@ -1745,10 +1754,18 @@ class FpJob(models.Model):
|
||||
# partner_id is the customer.
|
||||
Template._dispatch(event, self, partner=self.partner_id)
|
||||
except Exception as e:
|
||||
# F7 — surface on chatter. A missed customer notification
|
||||
# (e.g. "your parts have shipped") is invisible to the
|
||||
# operator until the customer complains; the chatter post
|
||||
# gives accounting / sales a recoverable signal.
|
||||
_logger.warning(
|
||||
"Job %s: notification %s dispatch failed: %s",
|
||||
self.name, event, e,
|
||||
)
|
||||
self.message_post(body=_(
|
||||
'Notification dispatch failed for event "%(ev)s": %(e)s. '
|
||||
'Send manually if the customer expected an update.'
|
||||
) % {'ev': event, 'e': e})
|
||||
|
||||
def _fp_create_delivery(self):
|
||||
"""Create a draft fusion.plating.delivery linked to this job.
|
||||
@@ -1787,9 +1804,16 @@ class FpJob(models.Model):
|
||||
delivery = Delivery.create(vals)
|
||||
self.delivery_id = delivery.id
|
||||
except Exception as e:
|
||||
# F7 — surface on chatter. Without this, the operator sees
|
||||
# "Job marked done" but no delivery record exists, and the
|
||||
# next milestone advance fails silently.
|
||||
_logger.warning(
|
||||
"Job %s: failed to auto-create delivery: %s", self.name, e,
|
||||
)
|
||||
self.message_post(body=_(
|
||||
'Delivery auto-create failed: %(e)s. '
|
||||
'Create the delivery manually from the Logistics menu.'
|
||||
) % {'e': e})
|
||||
|
||||
def _fp_resolve_delivery_defaults(self, Delivery):
|
||||
"""Build the create-vals for a fresh delivery, OR the
|
||||
|
||||
@@ -542,29 +542,179 @@ class FpJobStep(models.Model):
|
||||
return candidates[:1] or self.env['fp.job.step']
|
||||
|
||||
def _fp_has_uncaptured_step_inputs(self):
|
||||
"""True when the recipe step defines step_input prompts AND
|
||||
the user hasn't already saved values for this step's current
|
||||
run via the Record Inputs wizard.
|
||||
"""True when the recipe step has REQUIRED step_input prompts
|
||||
whose values haven't been recorded yet.
|
||||
|
||||
Previously this checked "any move with input values exists since
|
||||
date_started" — too coarse. Operator clicked Save on the dialog
|
||||
after filling ONE prompt and the helper went quiet, letting
|
||||
action_finish_and_advance bypass the dialog re-open even when
|
||||
4 of 5 required prompts were still empty (WO-30051 / Riya 2026-05-23).
|
||||
Now we count actual coverage per required input across every
|
||||
move recorded against this step.
|
||||
"""
|
||||
self.ensure_one()
|
||||
return bool(self._fp_missing_required_step_inputs())
|
||||
|
||||
def _fp_missing_required_step_inputs(self):
|
||||
"""Return the recordset of REQUIRED step_input prompts on this
|
||||
step's recipe node that have NO value recorded across any move
|
||||
from this step. Centralised helper — used by both
|
||||
_fp_has_uncaptured_step_inputs (re-open dialog) and
|
||||
_fp_check_step_inputs_complete (raise UserError on finish).
|
||||
"""
|
||||
self.ensure_one()
|
||||
node = self.recipe_node_id
|
||||
Prompt = self.env['fusion.plating.process.node.input']
|
||||
if not node:
|
||||
return False
|
||||
return Prompt
|
||||
prompts = node.input_ids
|
||||
if 'kind' in prompts._fields:
|
||||
prompts = prompts.filtered(lambda i: i.kind == 'step_input')
|
||||
if not prompts:
|
||||
return False
|
||||
# Has the operator already recorded values during this run?
|
||||
# Heuristic: any in-place fp.job.step.move (transfer_type='step')
|
||||
# for this step since date_started.
|
||||
Move = self.env['fp.job.step.move']
|
||||
already = Move.search_count([
|
||||
('from_step_id', '=', self.id),
|
||||
('transfer_type', '=', 'step'),
|
||||
('move_datetime', '>=', self.date_started or fields.Datetime.now()),
|
||||
])
|
||||
return already == 0
|
||||
if 'collect' in prompts._fields:
|
||||
prompts = prompts.filtered(lambda i: i.collect)
|
||||
required_prompts = prompts.filtered(lambda i: i.required)
|
||||
if not required_prompts:
|
||||
return Prompt
|
||||
Value = self.env['fp.job.step.move.input.value']
|
||||
recorded_input_ids = set(Value.search([
|
||||
('move_id.from_step_id', '=', self.id),
|
||||
('node_input_id', 'in', required_prompts.ids),
|
||||
]).mapped('node_input_id.id'))
|
||||
return required_prompts.filtered(
|
||||
lambda p: p.id not in recorded_input_ids
|
||||
)
|
||||
|
||||
def _fp_autosign_if_required(self):
|
||||
"""Auto-set signoff_user_id to the current user when the step has
|
||||
requires_signoff=True and no signoff has been recorded yet.
|
||||
|
||||
Called from button_finish just before the signoff gate. Captures
|
||||
WHO finished the step as the signer-of-record. For shops that
|
||||
need separate operator+supervisor sign-off, call action_signoff()
|
||||
explicitly from a supervisor session BEFORE the operator clicks
|
||||
Finish — that pre-sets signoff_user_id and this helper becomes a
|
||||
no-op.
|
||||
|
||||
Idempotent — never overwrites an existing signoff_user_id, so a
|
||||
manager pre-signing via action_signoff is preserved through the
|
||||
operator's Finish click.
|
||||
"""
|
||||
for step in self:
|
||||
if not step.requires_signoff:
|
||||
continue
|
||||
if step.signoff_user_id:
|
||||
continue # pre-signed (likely by a supervisor)
|
||||
# Use sudo because signoff_user_id is readonly=True at field
|
||||
# level; we still capture env.user.id (not SUPERUSER_ID) so
|
||||
# the audit trail shows who actually clicked.
|
||||
step.sudo().write({'signoff_user_id': self.env.user.id})
|
||||
|
||||
def _fp_check_signoff_complete(self):
|
||||
"""Raise UserError if the step has requires_signoff=True and
|
||||
signoff_user_id IS NULL. Aerospace / Nadcap need a named signer
|
||||
on every sign-off-required step; an unset signer breaks the
|
||||
audit chain.
|
||||
|
||||
Normally _fp_autosign_if_required (called from button_finish
|
||||
immediately before this gate) populates signoff_user_id with the
|
||||
finisher's id, so this gate only fires when:
|
||||
- The step is being finished via a code path that bypasses
|
||||
autosign (e.g. a migration script writing state='done').
|
||||
- The user has no env.user (background cron with no uid set).
|
||||
|
||||
Manager bypass via context fp_skip_signoff_gate=True for
|
||||
documented customer deviations. Bypasses are posted to chatter
|
||||
naming the user.
|
||||
"""
|
||||
if self.env.context.get('fp_skip_signoff_gate'):
|
||||
for step in self:
|
||||
if not step.requires_signoff:
|
||||
continue
|
||||
step.job_id.message_post(body=Markup(_(
|
||||
'Sign-off gate bypassed on step "<b>%s</b>" by %s. '
|
||||
'Documented deviation — no signer recorded.'
|
||||
)) % (step.name, self.env.user.name))
|
||||
return
|
||||
for step in self:
|
||||
if not step.requires_signoff:
|
||||
continue
|
||||
if step.signoff_user_id:
|
||||
continue
|
||||
raise UserError(_(
|
||||
'Step "%(step)s" cannot be finished — sign-off required '
|
||||
'but no signer recorded. Click "Sign Off" on the step '
|
||||
'(or have your supervisor sign before you finish). '
|
||||
'Managers can override via context flag '
|
||||
'fp_skip_signoff_gate=True for documented deviations.'
|
||||
) % {'step': step.name})
|
||||
|
||||
def action_signoff(self):
|
||||
"""Explicit sign-off action — sets signoff_user_id = env.user.id
|
||||
for the calling user. Use case: a supervisor reviews an operator's
|
||||
work and signs off BEFORE the operator clicks Finish. Once signed,
|
||||
the operator's Finish click passes the signoff gate without auto-
|
||||
assigning a different signer.
|
||||
|
||||
Idempotent — re-clicking by the same user is a no-op. A DIFFERENT
|
||||
user re-signing overwrites the prior signer (and chatters the change)
|
||||
so a senior supervisor can override a junior's premature sign-off
|
||||
without leaving the audit trail mute.
|
||||
"""
|
||||
for step in self:
|
||||
if not step.requires_signoff:
|
||||
raise UserError(_(
|
||||
'Step "%s" does not require sign-off — nothing to sign.'
|
||||
) % step.name)
|
||||
prior = step.signoff_user_id
|
||||
if prior and prior.id == self.env.user.id:
|
||||
continue # idempotent
|
||||
step.sudo().write({'signoff_user_id': self.env.user.id})
|
||||
if prior:
|
||||
step.job_id.message_post(body=Markup(_(
|
||||
'Sign-off on step "<b>%s</b>" reassigned from %s to %s.'
|
||||
)) % (step.name, prior.name, self.env.user.name))
|
||||
else:
|
||||
step.job_id.message_post(body=Markup(_(
|
||||
'Step "<b>%s</b>" signed off by %s.'
|
||||
)) % (step.name, self.env.user.name))
|
||||
return True
|
||||
|
||||
def _fp_check_step_inputs_complete(self):
|
||||
"""Raise UserError if the step has REQUIRED step_input prompts
|
||||
that haven't been recorded yet. AS9100 / Nadcap need a complete
|
||||
per-step data trail; finishing a step with missing prompts breaks
|
||||
the audit chain.
|
||||
|
||||
Manager bypass via context fp_skip_required_inputs_gate=True
|
||||
(e.g. paper-form catch-up or documented customer deviation).
|
||||
Bypasses are posted to chatter naming the user.
|
||||
"""
|
||||
if self.env.context.get('fp_skip_required_inputs_gate'):
|
||||
for step in self:
|
||||
step.job_id.message_post(body=Markup(_(
|
||||
'Required-inputs gate bypassed on step "<b>%s</b>" by %s. '
|
||||
'Documented deviation — review the step\'s prompts.'
|
||||
)) % (step.name, self.env.user.name))
|
||||
return
|
||||
for step in self:
|
||||
missing = step._fp_missing_required_step_inputs()
|
||||
if not missing:
|
||||
continue
|
||||
names = ', '.join('"%s"' % (p.name or '').strip() for p in missing)
|
||||
raise UserError(_(
|
||||
'Step "%(step)s" cannot be finished — %(n)s required '
|
||||
'input(s) not recorded yet: %(names)s. '
|
||||
'Click "Record Inputs" on the step row to enter the '
|
||||
'missing values, then finish. '
|
||||
'Managers can override via context flag '
|
||||
'fp_skip_required_inputs_gate=True for documented '
|
||||
'deviations.'
|
||||
) % {
|
||||
'step': step.name,
|
||||
'n': len(missing),
|
||||
'names': names,
|
||||
})
|
||||
|
||||
def _fp_open_input_wizard(self, advance_after=False):
|
||||
"""Open the Record Inputs OWL dialog (Sub 12e v4).
|
||||
@@ -593,93 +743,12 @@ class FpJobStep(models.Model):
|
||||
# _fp_open_input_wizard above adds the advance_after pathway used
|
||||
# only by action_finish_and_advance.
|
||||
|
||||
def button_finish(self):
|
||||
"""Override to:
|
||||
1) Auto-spawn a bake.window when a wet plating step finishes
|
||||
on a recipe that requires hydrogen-embrittlement relief
|
||||
(AS9100 / Nadcap compliance). Bake fields live on the
|
||||
recipe root post-promote-customer-spec.
|
||||
2) Post a chatter warning when duration_actual exceeds 1.5×
|
||||
duration_expected — silent overruns are a red flag for
|
||||
scheduling and costing.
|
||||
|
||||
Both actions are idempotent and never block the finish itself.
|
||||
"""
|
||||
result = super().button_finish()
|
||||
BW = self.env['fusion.plating.bake.window']
|
||||
Bath = self.env['fusion.plating.bath']
|
||||
for step in self:
|
||||
if step.state != 'done':
|
||||
continue
|
||||
# Duration-overrun chatter alert.
|
||||
if step.duration_expected and step.duration_actual:
|
||||
ratio = step.duration_actual / step.duration_expected
|
||||
if ratio >= 1.5:
|
||||
step.job_id.message_post(body=Markup(_(
|
||||
'⚠️ <b>Step "%s" ran %.1fx expected</b> — '
|
||||
'expected %.0f min, actual %.0f min. Investigate: '
|
||||
'equipment issue, training gap, or recipe time '
|
||||
'estimate too tight.'
|
||||
)) % (step.name, ratio, step.duration_expected,
|
||||
step.duration_actual))
|
||||
recipe_root = step.job_id.recipe_id
|
||||
if not recipe_root:
|
||||
continue
|
||||
requires = getattr(recipe_root, 'requires_bake_relief', False)
|
||||
window_hrs = getattr(recipe_root, 'bake_window_hours', 0.0)
|
||||
if not requires or not window_hrs:
|
||||
continue
|
||||
# Trigger only on the actual plating-out step. We want
|
||||
# exactly ONE bake.window per job (not one per step that
|
||||
# happens to have "plate" in the name). Heuristic:
|
||||
# - step.kind == 'wet' (clean, recipe-authored signal); OR
|
||||
# - the step name contains "plating" as a word
|
||||
# Explicit excludes: inspection / bake / mask / rack steps
|
||||
# whose names might happen to mention plating in passing
|
||||
# (e.g. "Post-plate Inspection").
|
||||
name_l = (step.name or '').lower()
|
||||
kind_match = step.kind == 'wet'
|
||||
name_match = bool(re.search(r'\bplating\b', name_l))
|
||||
excluded = any(kw in name_l for kw in (
|
||||
'inspect', 'inspection', 'bake', 'mask', 'rack',
|
||||
))
|
||||
if (not kind_match and not name_match) or excluded:
|
||||
continue
|
||||
# Idempotency — only one bake.window per (job, step).
|
||||
existing = BW.sudo().search([
|
||||
('part_ref', '=', step.job_id.name),
|
||||
('lot_ref', '=', f'step-{step.id}'),
|
||||
], limit=1)
|
||||
if existing:
|
||||
continue
|
||||
# Pick a bath: step.bath_id wins; fall back to the first
|
||||
# active bath in the facility (best-effort — operator can
|
||||
# correct on the bake.window record).
|
||||
bath = step.bath_id or Bath.sudo().search(
|
||||
[('facility_id', '=', step.facility_id.id)], limit=1,
|
||||
) if step.facility_id else False
|
||||
if not bath:
|
||||
bath = Bath.sudo().search([], limit=1)
|
||||
if not bath:
|
||||
_logger.warning(
|
||||
'Step %s: bake-window auto-spawn skipped — no bath '
|
||||
'configured.', step.name,
|
||||
)
|
||||
continue
|
||||
bw = BW.sudo().create({
|
||||
'bath_id': bath.id,
|
||||
'plate_exit_time': step.date_finished or fields.Datetime.now(),
|
||||
'window_hours': window_hrs,
|
||||
'part_ref': step.job_id.name,
|
||||
'lot_ref': f'step-{step.id}',
|
||||
'customer_ref': step.job_id.partner_id.display_name or '',
|
||||
'quantity': int(step.job_id.qty or 0),
|
||||
})
|
||||
step.job_id.message_post(body=Markup(_(
|
||||
'Bake window <b>%s</b> auto-created — %.1fh window from '
|
||||
'plate exit. Required by %s.'
|
||||
)) % (bw.name, window_hrs, bw.bake_required_by))
|
||||
return result
|
||||
# NOTE — the earlier duplicate `button_finish` definition that held
|
||||
# the duration-overrun + bake.window auto-spawn logic has been merged
|
||||
# into the canonical button_finish further down (line ~1130). Python
|
||||
# was silently keeping only the LAST definition in this class body,
|
||||
# so the bake.window auto-spawn was dead code for the entire WO-30051
|
||||
# era. Don't re-introduce a second button_finish here.
|
||||
|
||||
# ==================================================================
|
||||
# Phase 2 multi-serial — auto-promote serials on step transitions
|
||||
@@ -1070,18 +1139,112 @@ class FpJobStep(models.Model):
|
||||
return result
|
||||
|
||||
def button_finish(self):
|
||||
# Policy B — block until QA-005 complete (when customer requires it).
|
||||
"""Canonical button_finish — gates first, then super(), then
|
||||
post-finish side effects.
|
||||
|
||||
Gates (raise UserError, blocking finish):
|
||||
- Required step_input prompts recorded (S21 / WO-30051 fix).
|
||||
Manager bypass: fp_skip_required_inputs_gate=True.
|
||||
- Sign-off recorded when recipe step has requires_signoff=True
|
||||
(S22 / F1 audit fix). Auto-sign captures the finisher when
|
||||
no supervisor has pre-signed. Manager bypass:
|
||||
fp_skip_signoff_gate=True.
|
||||
- Contract Review (QA-005) complete when customer requires it.
|
||||
- Receiving gate — parts physically on site for this WO.
|
||||
(Racking-inspection gate removed — racking is a recipe step
|
||||
now, not a separate workflow. _fp_check_racking_inspection_
|
||||
complete() is kept as a helper for diagnostics.)
|
||||
|
||||
Post-finish (idempotent, never blocks):
|
||||
- Promote attached serials from in_process -> inspected on the
|
||||
terminal step of the job.
|
||||
- Chatter warning when duration_actual >= 1.5x duration_expected.
|
||||
- Auto-spawn a bake.window for wet plating steps on recipes
|
||||
flagged requires_bake_relief.
|
||||
"""
|
||||
# ----- Gates ----------------------------------------------------
|
||||
# Order matters: cheapest checks first. Required-inputs is a pure
|
||||
# ORM query; contract review and receiving may touch related models.
|
||||
self._fp_check_step_inputs_complete()
|
||||
# Sign-off: auto-capture the finisher's uid first (no-op when a
|
||||
# supervisor pre-signed via action_signoff), THEN gate. Gate only
|
||||
# fires when both autosign and explicit sign-off skipped (e.g.
|
||||
# migration scripts, background crons).
|
||||
self._fp_autosign_if_required()
|
||||
self._fp_check_signoff_complete()
|
||||
self._fp_check_contract_review_complete()
|
||||
# Receiving gate — same helper as button_start, exempts CR steps.
|
||||
self._fp_check_receiving_gate()
|
||||
# NOTE: racking inspection gate removed — racking is now a recipe
|
||||
# step, not a separate inspection workflow. _fp_check_racking_
|
||||
# inspection_complete() is kept as a helper for diagnostics but
|
||||
# no longer enforced from button_finish.
|
||||
|
||||
result = super().button_finish()
|
||||
|
||||
# ----- Post-finish side effects --------------------------------
|
||||
BW = self.env['fusion.plating.bake.window']
|
||||
Bath = self.env['fusion.plating.bath']
|
||||
for step in self:
|
||||
if step.state == 'done':
|
||||
step._fp_promote_serials_on_finish()
|
||||
if step.state != 'done':
|
||||
continue
|
||||
step._fp_promote_serials_on_finish()
|
||||
# Duration-overrun chatter alert.
|
||||
if step.duration_expected and step.duration_actual:
|
||||
ratio = step.duration_actual / step.duration_expected
|
||||
if ratio >= 1.5:
|
||||
step.job_id.message_post(body=Markup(_(
|
||||
'⚠️ <b>Step "%s" ran %.1fx expected</b> — '
|
||||
'expected %.0f min, actual %.0f min. Investigate: '
|
||||
'equipment issue, training gap, or recipe time '
|
||||
'estimate too tight.'
|
||||
)) % (step.name, ratio, step.duration_expected,
|
||||
step.duration_actual))
|
||||
# Bake-window auto-spawn — wet plating step + recipe flagged
|
||||
# requires_bake_relief. Heuristic identifies the actual
|
||||
# plate-out step (kind=wet OR "plating" as a word in name),
|
||||
# excluding inspection/bake/mask/rack steps that mention
|
||||
# plating in passing (e.g. "Post-plate Inspection").
|
||||
recipe_root = step.job_id.recipe_id
|
||||
if not recipe_root:
|
||||
continue
|
||||
requires = getattr(recipe_root, 'requires_bake_relief', False)
|
||||
window_hrs = getattr(recipe_root, 'bake_window_hours', 0.0)
|
||||
if not requires or not window_hrs:
|
||||
continue
|
||||
name_l = (step.name or '').lower()
|
||||
kind_match = step.kind == 'wet'
|
||||
name_match = bool(re.search(r'\bplating\b', name_l))
|
||||
excluded = any(kw in name_l for kw in (
|
||||
'inspect', 'inspection', 'bake', 'mask', 'rack',
|
||||
))
|
||||
if (not kind_match and not name_match) or excluded:
|
||||
continue
|
||||
existing = BW.sudo().search([
|
||||
('part_ref', '=', step.job_id.name),
|
||||
('lot_ref', '=', f'step-{step.id}'),
|
||||
], limit=1)
|
||||
if existing:
|
||||
continue
|
||||
bath = step.bath_id or Bath.sudo().search(
|
||||
[('facility_id', '=', step.facility_id.id)], limit=1,
|
||||
) if step.facility_id else False
|
||||
if not bath:
|
||||
bath = Bath.sudo().search([], limit=1)
|
||||
if not bath:
|
||||
_logger.warning(
|
||||
'Step %s: bake-window auto-spawn skipped — no bath '
|
||||
'configured.', step.name,
|
||||
)
|
||||
continue
|
||||
bw = BW.sudo().create({
|
||||
'bath_id': bath.id,
|
||||
'plate_exit_time': step.date_finished or fields.Datetime.now(),
|
||||
'window_hours': window_hrs,
|
||||
'part_ref': step.job_id.name,
|
||||
'lot_ref': f'step-{step.id}',
|
||||
'customer_ref': step.job_id.partner_id.display_name or '',
|
||||
'quantity': int(step.job_id.qty or 0),
|
||||
})
|
||||
step.job_id.message_post(body=Markup(_(
|
||||
'Bake window <b>%s</b> auto-created — %.1fh window from '
|
||||
'plate exit. Required by %s.'
|
||||
)) % (bw.name, window_hrs, bw.bake_required_by))
|
||||
return result
|
||||
|
||||
# ==================================================================
|
||||
|
||||
@@ -433,6 +433,31 @@ export class FpRecordInputsDialog extends Component {
|
||||
this.state.rows.splice(idx, 1);
|
||||
}
|
||||
|
||||
// Mirrors fp.job.step.input.wizard.line._has_value() Python helper.
|
||||
// Critical: the wizard SKIPS rows where _has_value() is False when
|
||||
// creating fp.job.step.move.input.value records, so the server-side
|
||||
// required-inputs gate considers them "not recorded". This client
|
||||
// check must match that semantic exactly or the server will reject
|
||||
// saves the operator thought were complete.
|
||||
_fpRowHasValue(row) {
|
||||
if (row.input_type === "photo") return !!row.photo_value;
|
||||
if (row.input_type === "multi_point_thickness") {
|
||||
return !!(row.point_1 || row.point_2 || row.point_3
|
||||
|| row.point_4 || row.point_5);
|
||||
}
|
||||
if (row.input_type === "bath_chemistry_panel") {
|
||||
return !!(row.panel_ph || row.panel_concentration
|
||||
|| row.panel_temperature || row.panel_bath_id);
|
||||
}
|
||||
if (row.input_type === "pass_fail") return !!row._passfail_chosen;
|
||||
// Boolean: value_boolean===true counts; untouched/false is
|
||||
// treated as no-value to match Python `any([..., self.value_
|
||||
// boolean, ...])`. Operators MUST affirmatively check the box.
|
||||
return !!(row.value_text || row.value_number
|
||||
|| row.value_boolean || row.value_date
|
||||
|| row.value_min || row.value_max);
|
||||
}
|
||||
|
||||
// The "current" initials value across all rows — a row counts as a
|
||||
// signature/initials field when ``_fpIsInitialsField`` is true.
|
||||
// Returns the most-recently-set value (last write wins) or empty.
|
||||
@@ -477,6 +502,26 @@ export class FpRecordInputsDialog extends Component {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Required-prompt gate when finishing the step (advanceAfter=true).
|
||||
// Mirrors fp.job.step._fp_check_step_inputs_complete server-side
|
||||
// so the operator sees the missing fields instantly instead of
|
||||
// getting a server roundtrip error after the save commits. Partial
|
||||
// saves are still allowed when the dialog is opened from the
|
||||
// per-row Record button (advanceAfter=false).
|
||||
if (this.props.advanceAfter) {
|
||||
const missing = this.state.rows
|
||||
.filter((r) => r.required && !this._fpRowHasValue(r))
|
||||
.map((r) => r.name || _t("(unnamed)"));
|
||||
if (missing.length) {
|
||||
this.notification.add(
|
||||
_t("Cannot finish step — %n required prompt(s) missing: %list")
|
||||
.replace("%n", missing.length)
|
||||
.replace("%list", missing.map((n) => `"${n}"`).join(", ")),
|
||||
{ type: "danger", sticky: true },
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.state.saving = true;
|
||||
const payload = this.state.rows.map((r) => {
|
||||
// When the prompt expects a range entry (min + max readings),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
'name': 'Fusion Plating — Shop Floor',
|
||||
'version': '19.0.30.2.0',
|
||||
'version': '19.0.30.6.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Shop-floor tablet stations, QR scanning, bake window enforcer, '
|
||||
'first-piece inspection gates.',
|
||||
|
||||
@@ -203,6 +203,13 @@ class FpTabletMoveController(http.Controller):
|
||||
for prompt_id, value in (prompt_values or {}).items():
|
||||
self._capture_prompt_value(move, int(prompt_id), value)
|
||||
|
||||
# S23 — required transition-input gate. Runs AFTER value capture
|
||||
# so the operator gets credit for whatever they filled in. Raises
|
||||
# UserError if to_step.requires_transition_form=True and any
|
||||
# required transition_input prompt has no value. Rollback unwinds
|
||||
# the move + value rows. Manager bypass: fp_skip_transition_form.
|
||||
move._fp_check_transition_inputs_complete()
|
||||
|
||||
# Advance qty_at_step counters
|
||||
to_step.qty_at_step_start = (to_step.qty_at_step_start or 0) + qty
|
||||
from_step.qty_at_step_finish = (from_step.qty_at_step_finish or 0) + qty
|
||||
@@ -298,6 +305,42 @@ class FpTabletMoveController(http.Controller):
|
||||
rack = Rack.browse(rack_id)
|
||||
to_step = Step.browse(to_step_id)
|
||||
|
||||
# S23 — pre-check: rack moves don't capture transition prompts
|
||||
# (no per-move dialog), so if to_step.requires_transition_form
|
||||
# we must reject up-front and force the operator through Move
|
||||
# Parts (which has the form UI). Without this check, rack moves
|
||||
# silently bypass the audit gate that Move Parts enforces.
|
||||
if (to_step.requires_transition_form
|
||||
and not request.env.context.get('fp_skip_transition_form')):
|
||||
# Use the same model helper for consistency — build a dummy
|
||||
# in-memory move to compute "missing" set, then surface a
|
||||
# clear message that points operators at the right tool.
|
||||
recipe_node = to_step.recipe_node_id
|
||||
required_prompts = recipe_node.input_ids if recipe_node else (
|
||||
request.env['fusion.plating.process.node.input']
|
||||
)
|
||||
if 'kind' in required_prompts._fields:
|
||||
required_prompts = required_prompts.filtered(
|
||||
lambda i: i.kind == 'transition_input')
|
||||
required_prompts = required_prompts.filtered(
|
||||
lambda i: i.required)
|
||||
if required_prompts:
|
||||
names = ', '.join(
|
||||
'"%s"' % (p.name or '').strip()
|
||||
for p in required_prompts
|
||||
)
|
||||
raise UserError(_(
|
||||
'Step "%(step)s" requires a transition form '
|
||||
'(%(n)s required prompt(s): %(names)s). '
|
||||
'Use Move Parts for one batch at a time so the form '
|
||||
'can be filled in, or have a manager override with '
|
||||
'context flag fp_skip_transition_form=True.'
|
||||
) % {
|
||||
'step': to_step.name,
|
||||
'n': len(required_prompts),
|
||||
'names': names,
|
||||
})
|
||||
|
||||
moves = []
|
||||
for batch in Step.search([('rack_id', '=', rack.id)]):
|
||||
qty = (batch.qty_done or 0) - (batch.qty_scrapped or 0)
|
||||
|
||||
@@ -35,7 +35,12 @@ export class FpPinPad extends Component {
|
||||
async _press(digit) {
|
||||
if (this.state.submitting) return;
|
||||
if (this.state.pin.length >= 4) return;
|
||||
this.state.pin = this.state.pin + digit;
|
||||
// Defensive: coerce to string in JS rather than the template
|
||||
// because OWL templates don't expose `String` as a callable
|
||||
// (Critical Rule 20 in CLAUDE.md). Callers pass strings already
|
||||
// via the string array in pin_pad.xml; this is a belt-and-braces
|
||||
// guard for any future caller passing a numeric digit.
|
||||
this.state.pin = this.state.pin + String(digit);
|
||||
this.state.error = "";
|
||||
if (this.state.pin.length === 4) {
|
||||
await this._submit();
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// Auto-refresh: every 15s.
|
||||
// =============================================================================
|
||||
|
||||
import { Component, useState, onMounted, onWillUnmount } from "@odoo/owl";
|
||||
import { Component, markup, useState, onMounted, onWillUnmount } from "@odoo/owl";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { rpc } from "@web/core/network/rpc";
|
||||
import { fpRpc } from "./services/fp_rpc";
|
||||
@@ -64,6 +64,19 @@ export class FpJobWorkspace extends Component {
|
||||
try {
|
||||
const res = await rpc("/fp/workspace/load", { job_id: this.state.jobId });
|
||||
if (res && res.ok) {
|
||||
// Chatter bodies arrive as plain HTML strings off the RPC.
|
||||
// The template renders them via `t-out="msg.body"`, which
|
||||
// HTML-ESCAPES plain JS strings unless they're tagged with
|
||||
// markup() from @odoo/owl. Without this wrap the operator
|
||||
// sees literal `<p>` and `<b>` tags instead of formatted
|
||||
// text (caught 2026-05-23 — Notes panel showing raw HTML).
|
||||
if (res.chatter && res.chatter.length) {
|
||||
for (const m of res.chatter) {
|
||||
if (m && typeof m.body === "string") {
|
||||
m.body = markup(m.body);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.state.data = res;
|
||||
} else if (res && res.error) {
|
||||
this.notification.add(res.error, { type: "danger" });
|
||||
@@ -75,8 +88,18 @@ export class FpJobWorkspace extends Component {
|
||||
|
||||
// ---- Navigation --------------------------------------------------------
|
||||
onBack() {
|
||||
// Close workspace; return to whatever spawned the action
|
||||
this.action.doAction({ type: "ir.actions.act_window_close" });
|
||||
// The workspace is opened from the Landing kanban with
|
||||
// target: "current", which REPLACES the current action and
|
||||
// wipes the backstack. So `act_window_close` did nothing —
|
||||
// there's no parent action to close to. Navigate explicitly
|
||||
// to the Shop Floor Landing instead, which works whether the
|
||||
// workspace was opened from the kanban, a QR scan, the manager
|
||||
// dashboard, or a direct URL. (Bug caught 2026-05-23.)
|
||||
this.action.doAction({
|
||||
type: "ir.actions.client",
|
||||
tag: "fp_shopfloor_landing",
|
||||
target: "current",
|
||||
});
|
||||
}
|
||||
|
||||
// ---- Hand-Off (Phase 6.2) ---------------------------------------------
|
||||
|
||||
@@ -176,13 +176,42 @@ $_lan-text-hex: #1d1d1f;
|
||||
}
|
||||
|
||||
// ---- Kanban board ------------------------------------------------------
|
||||
// Recipe authors keep adding work centres (Anodize, Strip, Etch, Bake,
|
||||
// Mask, Rack, Inspect, Ship…) so the kanban must accommodate both
|
||||
// FEW columns (early-shop layouts) AND MANY columns (mature shops with
|
||||
// 15+ stations). Two design moves to handle both:
|
||||
// 1. Columns use `flex: 1 0 200px` — basis 200px, GROW into spare
|
||||
// space (3 cols on a 1200px screen → each becomes 400px), but
|
||||
// NEVER SHRINK below 200px so 15+ cols stay readable and scroll
|
||||
// horizontally. Max 320px caps the growth so a single-column
|
||||
// kanban doesn't span 1200px of empty whitespace.
|
||||
// 2. Custom-styled horizontal scrollbar — the default browser bar
|
||||
// is invisible until hover on most platforms; users had no idea
|
||||
// more columns existed off-screen. Now there's a persistent thin
|
||||
// bar at the bottom of the board.
|
||||
.o_fp_landing_board {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
gap: 0.6rem;
|
||||
padding: 0.6rem 1rem 1rem;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
align-items: stretch;
|
||||
|
||||
// Custom scrollbar — visible enough that users notice more columns
|
||||
// exist off-screen without being obnoxiously large.
|
||||
&::-webkit-scrollbar { height: 10px; }
|
||||
&::-webkit-scrollbar-track {
|
||||
background: $_lan-page-hex;
|
||||
border-radius: 5px;
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: $_lan-border-hex;
|
||||
border-radius: 5px;
|
||||
&:hover { background: darken(#d8dadd, 10%); }
|
||||
}
|
||||
scrollbar-width: thin; // Firefox
|
||||
scrollbar-color: $_lan-border-hex $_lan-page-hex;
|
||||
}
|
||||
|
||||
.o_fp_landing_empty {
|
||||
@@ -194,13 +223,16 @@ $_lan-text-hex: #1d1d1f;
|
||||
}
|
||||
|
||||
.o_fp_landing_col {
|
||||
flex: 0 0 240px;
|
||||
flex: 1 0 200px; // grow into spare, never shrink below 200px
|
||||
min-width: 200px;
|
||||
max-width: 320px; // cap growth so single col doesn't span 1200px
|
||||
background: $_lan-card-hex;
|
||||
border: 1px solid $_lan-border-hex;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 100%;
|
||||
overflow: hidden; // contain inner sticky header within border-radius
|
||||
|
||||
&.o_fp_drop_target {
|
||||
outline: 2px dashed #0071e3;
|
||||
@@ -209,6 +241,14 @@ $_lan-text-hex: #1d1d1f;
|
||||
}
|
||||
|
||||
.o_fp_landing_col_head {
|
||||
// Sticky inside the column body so as the operator scrolls through
|
||||
// many cards, they always see WHICH station they're looking at.
|
||||
// (Caught 2026-05-23 — long card lists in Oven Baking made operators
|
||||
// lose track of which column they were scrolling.)
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
background: $_lan-card-hex;
|
||||
padding: 0.4rem 0.7rem;
|
||||
border-bottom: 1px solid $_lan-border-hex;
|
||||
display: flex;
|
||||
@@ -218,7 +258,14 @@ $_lan-text-hex: #1d1d1f;
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.o_fp_landing_col_name { flex: 1; }
|
||||
.o_fp_landing_col_name {
|
||||
flex: 1;
|
||||
// Truncate long work-centre names instead of wrapping (which would
|
||||
// push the count badge to a second line and shift card content).
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.o_fp_landing_col_count {
|
||||
background: $_lan-page-hex;
|
||||
@@ -226,6 +273,7 @@ $_lan-text-hex: #1d1d1f;
|
||||
padding: 0.1rem 0.5rem;
|
||||
font-size: 0.7rem;
|
||||
color: var(--text-secondary, #777);
|
||||
flex-shrink: 0; // don't squeeze the count when the name is long
|
||||
}
|
||||
|
||||
.o_fp_landing_col_body {
|
||||
|
||||
@@ -15,9 +15,16 @@
|
||||
<div t-if="state.error" class="o_fp_pin_error" t-esc="state.error"/>
|
||||
|
||||
<div class="o_fp_pin_grid">
|
||||
<t t-foreach="[1,2,3,4,5,6,7,8,9]" t-as="d" t-key="d">
|
||||
<!-- IMPORTANT: digits MUST be string literals here.
|
||||
OWL templates only expose `Math` as a JS global —
|
||||
`String`, `Number`, `Array`, etc. are NOT in template
|
||||
scope. Calling `String(d)` throws "v2 is not a
|
||||
function" because the compiled template references
|
||||
a global named String that doesn't exist. Keep this
|
||||
array as strings; do any type coercion in JS. -->
|
||||
<t t-foreach="['1','2','3','4','5','6','7','8','9']" t-as="d" t-key="d">
|
||||
<button class="o_fp_pin_key"
|
||||
t-on-click="() => this._press(String(d))"
|
||||
t-on-click="() => this._press(d)"
|
||||
t-att-disabled="state.submitting">
|
||||
<t t-esc="d"/>
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user