Files
Odoo-Modules/fusion_plating/fusion_plating_certificates/views/fp_certificate_views.xml
gsinghpal 269f9984ef 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>
2026-05-24 01:45:39 -04:00

262 lines
14 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- ============================================================ -->
<!-- LIST VIEW -->
<!-- ============================================================ -->
<record id="fp_certificate_view_list" model="ir.ui.view">
<field name="name">fp.certificate.list</field>
<field name="model">fp.certificate</field>
<field name="arch" type="xml">
<list default_order="issue_date desc"
decoration-muted="state == 'draft'"
decoration-success="state == 'issued'"
decoration-danger="state == 'voided'">
<field name="issue_date"/>
<field name="name"/>
<field name="certificate_type" widget="badge"/>
<field name="partner_id"/>
<field name="part_number"/>
<field name="po_number"/>
<field name="entech_wo_number"/>
<field name="process_description"/>
<field name="quantity_shipped"/>
<field name="issued_by_id"/>
<field name="state" widget="badge"
decoration-info="state == 'draft'"
decoration-success="state == 'issued'"
decoration-danger="state == 'voided'"/>
</list>
</field>
</record>
<!-- ============================================================ -->
<!-- FORM VIEW -->
<!-- ============================================================ -->
<record id="fp_certificate_view_form" model="ir.ui.view">
<field name="name">fp.certificate.form</field>
<field name="model">fp.certificate</field>
<field name="arch" type="xml">
<form>
<header>
<!-- Phase D5 — Nadcap certs are QM-only to Issue per spec
section 2.C (FAIR/Nadcap sign/issue restricted to
Quality Manager). Strategy B: single button visible
to all when state=draft and cert_type is routine
(coc/thickness_report/mill_test/customer_specific);
hidden for non-QM when cert_type=nadcap_cert. The
ir.rule from Phase C also restricts model writes on
FAIR/Nadcap so model-layer enforcement is independent.
No separate action_sign exists on this model — Issue
is the sign + publish action. -->
<button name="action_issue" string="Issue"
type="object" class="btn-primary"
invisible="state != 'draft' or (certificate_type == 'nadcap_cert' and not user_has_groups('fusion_plating.group_fp_quality_manager'))"/>
<!-- Print = the same EN report action the gear-menu
Print > Certificate of Conformance (English)
calls. Routes through fusion_pdf_preview's
report interceptor automatically. For the
French variant or any other language report,
use the gear menu. -->
<button name="%(fusion_plating_reports.action_report_coc_en)d"
string="Print"
type="action" class="btn-secondary"
icon="fa-print"/>
<button name="action_open_void_wizard" string="Void"
type="object" class="btn-danger"
invisible="state != 'issued'"/>
<button name="action_send_to_customer" string="Send to Customer"
type="object"
invisible="state != 'issued'"/>
<button name="action_reset_to_draft" string="Reset to Draft"
type="object" class="btn-secondary"
icon="fa-undo"
confirm="Reset this certificate to draft? You'll be able to edit and re-issue. The previously-issued PDF stays attached for audit."
invisible="state == 'draft'"/>
<field name="state" widget="statusbar"
statusbar_visible="draft,issued"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="action_view_traceability"
type="object"
class="oe_stat_button"
icon="fa-sitemap"
invisible="batch_count == 0">
<field name="batch_count" widget="statinfo"
string="Batches"/>
</button>
</div>
<div class="oe_title">
<h1>
<field name="name" readonly="1"/>
</h1>
</div>
<!-- Main info — collapsed from 3 separate groups
into 1 to eliminate the dead rows that
appeared when one sub-group ran shorter than
the other. Left column is identity / signer /
dates; right column is part / process / qty /
derived stats. Reorganized 2026-05-21. -->
<group>
<group>
<field name="certificate_type"/>
<field name="partner_id"/>
<field name="contact_partner_id"
options="{'no_create': True}"
invisible="not partner_id"/>
<field name="sale_order_id"/>
<field name="entech_wo_number"/>
<field name="portal_job_id"/>
<field name="issue_date"/>
<field name="issued_by_id"/>
<field name="certified_by_id"/>
<field name="body_style"/>
</group>
<group>
<field name="part_number"/>
<field name="process_description"/>
<field name="spec_reference"/>
<field name="po_number"/>
<field name="customer_job_no"/>
<field name="quantity_shipped"/>
<field name="nc_quantity"/>
<field name="reading_count" readonly="1"/>
<field name="mean_nip_mils" readonly="1"/>
</group>
</group>
<!-- SPC rebalanced — spec/min/max on the left,
derived stats on the right; trend_explanation
spans both columns so the long message doesn't
get cropped. -->
<group string="SPC — Statistical Process Control">
<group>
<field name="spec_min_mils"/>
<field name="spec_max_mils"/>
<field name="min_reading_mils" readonly="1"/>
<field name="max_reading_mils" readonly="1"/>
</group>
<group>
<field name="std_dev_mils" readonly="1"/>
<field name="cpk" readonly="1"/>
<field name="cpk_status" readonly="1" widget="badge"
decoration-success="cpk_status in ('capable','excellent')"
decoration-warning="cpk_status == 'marginal'"
decoration-danger="cpk_status == 'incapable'"
decoration-muted="cpk_status == 'insufficient'"/>
<field name="trend_alert" readonly="1" widget="badge"
decoration-success="trend_alert == 'ok'"
decoration-warning="trend_alert == 'warning'"
decoration-danger="trend_alert == 'alert'"/>
</group>
<field name="trend_explanation" readonly="1" colspan="2"
invisible="trend_alert == 'ok'"/>
</group>
<notebook>
<page string="Thickness Readings" name="readings">
<field name="thickness_reading_ids">
<list editable="bottom">
<field name="reading_number"/>
<field name="nip_mils"/>
<field name="ni_percent"/>
<field name="p_percent"/>
<field name="position_label"/>
<field name="equipment_model"/>
<field name="operator_id"/>
<field name="reading_datetime"/>
</list>
</field>
</page>
<page string="Certificate PDF" name="pdf">
<group>
<field name="attachment_id"/>
</group>
</page>
<page string="Void" name="void"
invisible="state != 'voided'">
<field name="void_reason"/>
</page>
<page string="Notes" name="notes">
<field name="notes"/>
</page>
</notebook>
</sheet>
<chatter>
<field name="message_follower_ids"/>
<field name="activity_ids"/>
<field name="message_ids"/>
</chatter>
</form>
</field>
</record>
<!-- ============================================================ -->
<!-- SEARCH VIEW -->
<!-- ============================================================ -->
<record id="fp_certificate_view_search" model="ir.ui.view">
<field name="name">fp.certificate.search</field>
<field name="model">fp.certificate</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<field name="partner_id"/>
<field name="part_number"/>
<field name="po_number"/>
<field name="entech_wo_number"/>
<separator/>
<filter name="filter_coc" string="CoC"
domain="[('certificate_type', '=', 'coc')]"/>
<filter name="filter_thickness" string="Thickness Report"
domain="[('certificate_type', '=', 'thickness_report')]"/>
<filter name="filter_mill_test" string="Mill Test"
domain="[('certificate_type', '=', 'mill_test')]"/>
<filter name="filter_nadcap" string="Nadcap"
domain="[('certificate_type', '=', 'nadcap_cert')]"/>
<separator/>
<filter name="filter_draft" string="Draft"
domain="[('state', '=', 'draft')]"/>
<filter name="filter_issued" string="Issued"
domain="[('state', '=', 'issued')]"/>
<filter name="filter_voided" string="Voided"
domain="[('state', '=', 'voided')]"/>
<separator/>
<filter name="filter_this_week" string="This Week"
domain="[('issue_date', '>=', (context_today() - relativedelta(weeks=1)).strftime('%Y-%m-%d'))]"/>
<filter name="filter_this_month" string="This Month"
domain="[('issue_date', '>=', context_today().strftime('%Y-%m-01'))]"/>
<separator/>
<group>
<filter name="group_customer" string="Customer"
context="{'group_by': 'partner_id'}"/>
<filter name="group_type" string="Type"
context="{'group_by': 'certificate_type'}"/>
<filter name="group_issued_by" string="Issued By"
context="{'group_by': 'issued_by_id'}"/>
<filter name="group_month" string="Month"
context="{'group_by': 'issue_date:month'}"/>
</group>
</search>
</field>
</record>
<!-- ============================================================ -->
<!-- WINDOW ACTION -->
<!-- ============================================================ -->
<record id="action_fp_certificate" model="ir.actions.act_window">
<field name="name">Certificates</field>
<field name="res_model">fp.certificate</field>
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="fp_certificate_view_search"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create your first certificate
</p>
<p>
Certificates of Conformance, thickness reports, and other quality
documents are tracked here.
</p>
</field>
</record>
</odoo>