feat(plating-views): Layer 3 — field/button gates per role

Phase D Task D5 of permissions overhaul. Adds explicit groups= to
form-level elements so non-matching roles don't even SEE the buttons
they can't use:

- SO Confirm button → group_fp_sales_manager (Sales Rep sees the SO
  in draft but no Confirm button — matches model-level gate from Phase G)
- SO pricing fields (price_unit/subtotal/total/untaxed/tax) →
  group_fp_sales_rep (Technician/Shop Manager don't see pricing if
  they navigate to an SO)
- Partner Account Hold tab → group_fp_manager (was the fold-in
  group_fp_accounting; the audit-finding-11 _administrator typo lives
  in res_partner.py and is Phase G's fix)
- CAPA Close + all state-transition buttons → group_fp_quality_manager;
  edit fields use readonly="not user_has_groups(...)" so Manager
  retains read+comment per spec section 2.C
- Audit Start/Findings/Close buttons → group_fp_quality_manager
- AVL Approve/Suspend/Reinstate/Remove → group_fp_quality_manager
  (model uses Suspend+Remove instead of spec's literal 'Disqualify';
  both surfaces gated, semantics match)
- Customer Spec edit fields → readonly for non-QM (Manager keeps
  read access per spec; only inputs lock)
- FAIR Approve/Reject buttons → group_fp_quality_manager (Submit-
  for-Review and Reset stay open to whoever created the FAIR)
- Certificate Issue button — Strategy B chosen: single button hidden
  when cert_type=nadcap_cert AND user is not QM. Cleaner than splitting
  into two buttons; no separate action_sign exists on fp.certificate
  (Issue is the sign+publish action). FAIR lives in its own model;
  fp.certificate only has nadcap_cert as a special type. The ir.rule
  from Phase C enforces model-level writes independently.
- CGP form buttons (7 view files: ai, controlled_good, psa,
  receipt_shipment, registration, security_incident, visitor) →
  group_fp_quality_manager on every action button

Defense in depth: ir.rules and ACLs (from Phases B + C) already
restrict model access. These view gates are the UI layer that
matches.

Concerns:
- Spec line 192 names 'sale.order view — x_fc_account_hold_override'
  but no such field exists in the codebase. Closest practical match
  was the partner-side Account Hold management tab, which already had
  a group= attribute. Re-gated there; no SO-side field to gate.
- AVL model has no action_disqualify per spec; uses suspend+remove.
  Both gated to QM.
- fp.certificate has no action_sign (only action_issue). FAIR's
  approve/reject covers the FAIR side; nadcap-cert Issue covers the
  cert side via Strategy B.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-24 01:45:39 -04:00
parent 9e5c23f37d
commit 269f9984ef
20 changed files with 222 additions and 74 deletions

View File

@@ -35,20 +35,30 @@
<field name="arch" type="xml">
<form string="CAPA">
<header>
<!-- Phase D5 — every state-transition button is QM-only.
Per spec section 2.C, Manager has read+comment only;
QM owns CRUD + close + effectiveness verification. -->
<button name="action_start_analysis" string="Start Analysis" type="object"
class="oe_highlight" invisible="state != 'draft'"/>
class="oe_highlight" invisible="state != 'draft'"
groups="fusion_plating.group_fp_quality_manager"/>
<button name="action_start_implementation" string="Implement" type="object"
invisible="state != 'analysis'"/>
invisible="state != 'analysis'"
groups="fusion_plating.group_fp_quality_manager"/>
<button name="action_start_verification" string="Verify" type="object"
invisible="state != 'implementation'"/>
invisible="state != 'implementation'"
groups="fusion_plating.group_fp_quality_manager"/>
<button name="action_mark_effective" string="Mark Effective" type="object"
class="oe_highlight" invisible="state != 'verification'"/>
class="oe_highlight" invisible="state != 'verification'"
groups="fusion_plating.group_fp_quality_manager"/>
<button name="action_mark_not_effective" string="Not Effective" type="object"
invisible="state != 'verification'"/>
invisible="state != 'verification'"
groups="fusion_plating.group_fp_quality_manager"/>
<button name="action_close" string="Close" type="object"
invisible="state not in ('effective','not_effective')"/>
invisible="state not in ('effective','not_effective')"
groups="fusion_plating.group_fp_quality_manager"/>
<button name="action_reset_to_draft" string="Reset" type="object"
invisible="state == 'draft'"/>
invisible="state == 'draft'"
groups="fusion_plating.group_fp_quality_manager"/>
<field name="state" widget="statusbar"
statusbar_visible="draft,analysis,implementation,verification,effective,closed"/>
</header>
@@ -57,33 +67,48 @@
<label for="name"/>
<h1><field name="name" readonly="1"/></h1>
</div>
<!-- Phase D5 — editable fields readonly for non-QM. Per
spec section 2.C, Manager retains read+comment only;
QM owns CRUD. Form stays visible (Manager needs to
read + chatter); only the inputs lock for non-QM. -->
<group>
<group>
<field name="type"/>
<field name="ncr_id"/>
<field name="type"
readonly="not user_has_groups('fusion_plating.group_fp_quality_manager')"/>
<field name="ncr_id"
readonly="not user_has_groups('fusion_plating.group_fp_quality_manager')"/>
<field name="facility_id" readonly="1"/>
<field name="owner_id"/>
<field name="owner_id"
readonly="not user_has_groups('fusion_plating.group_fp_quality_manager')"/>
</group>
<group>
<field name="due_date"/>
<field name="due_date"
readonly="not user_has_groups('fusion_plating.group_fp_quality_manager')"/>
<field name="is_overdue" readonly="1"/>
<field name="verification_date"/>
<field name="verification_by_id"/>
<field name="verification_date"
readonly="not user_has_groups('fusion_plating.group_fp_quality_manager')"/>
<field name="verification_by_id"
readonly="not user_has_groups('fusion_plating.group_fp_quality_manager')"/>
<field name="is_effective" readonly="1"/>
</group>
</group>
<notebook>
<page string="Description">
<field name="description"/>
<field name="description"
readonly="not user_has_groups('fusion_plating.group_fp_quality_manager')"/>
</page>
<page string="Root Cause Analysis">
<field name="root_cause_analysis" placeholder="5 Whys, fishbone, or any other structured method."/>
<field name="root_cause_analysis"
placeholder="5 Whys, fishbone, or any other structured method."
readonly="not user_has_groups('fusion_plating.group_fp_quality_manager')"/>
</page>
<page string="Action Plan">
<field name="action_plan"/>
<field name="action_plan"
readonly="not user_has_groups('fusion_plating.group_fp_quality_manager')"/>
</page>
<page string="Effectiveness">
<field name="effectiveness_notes"/>
<field name="effectiveness_notes"
readonly="not user_has_groups('fusion_plating.group_fp_quality_manager')"/>
</page>
</notebook>
</sheet>