Files
Odoo-Modules/fusion_plating/fusion_plating_certificates/views/fp_certificate_views.xml
gsinghpal a623c6684d fix(fusion_plating): bug review fixes + progress/net-terms invoicing + formal CoC rebuild
Bug review fixes (found by code review + live QWeb error):
- report_fp_sale.xml: product_uom → product_uom_id (Odoo 19 renamed;
  was raising KeyError during PDF render, blocking all sale-order prints)
- mrp_production.button_mark_done: add idempotency guard on delivery
  auto-create (was duplicating on every re-close)
- fp.certificate._compute_batch_ids: use empty recordset instead of
  False for Many2many computed fields
- fp_notification_template._collect_attachments: collapse attach_quotation
  + attach_sale_order into a single render so email doesn't double-attach
  the same PDF
- fp.operator.certification: SQL unique on computed state was unreliable;
  added explicit `revoked` boolean, made state pure-compute, replaced
  SQL constraint with @api.constrains that checks active-only uniqueness;
  has_active_cert now reads revoked + expires_date directly (no stale
  stored state between nightly recomputes)

Two missing invoice strategies implemented + 1 pre-existing deposit bug fix:
- Progress Billing: new x_fc_progress_initial_percent field on sale.order;
  _create_progress_initial_invoice bills the configured % on SO confirm
  via down-payment wizard, _create_final_balance_invoice bills the
  remainder on delivery
- Net Terms: no invoice on confirm; full invoice auto-created when
  fusion.plating.delivery.action_mark_delivered fires
- Fix for deposit (pre-existing, silent): sale.advance.payment.inv
  reads active_ids at wizard-create time, not on create_invoices();
  context was being set on the wrong call, so every deposit attempt
  raised "Expected singleton" and message-posted to chatter instead
  of actually invoicing
- New fusion_plating_invoicing/models/fp_delivery.py hooks
  action_mark_delivered to dispatch final invoice for progress/net_terms
- fp.direct.order.wizard + SO form surface the progress_initial_percent
  field (conditional on strategy)

Report styling cleanup:
- Hide DISCOUNT column from sale + invoice landscape reports unless at
  least one line has a non-zero discount; colspan auto-adjusts
- Replace hardcoded #0066a1 in all reports with company.primary_color
  driven by doc.company_id → company → user.company_id fallback chain,
  with #1d1f1e as ultimate fallback; new .fp-header-primary class
  exposes the colour for inline section headers (CARGO DESCRIPTION,
  PAYMENT DETAILS, OPERATOR SIGN-OFF, etc.) so they retint with the
  company theme without template edits

Certificate of Conformance — formal ENTECH-style rebuild:
- New res.company fields: x_fc_owner_user_id (default signer, sig from
  hr.employee.signature), x_fc_coc_signature_override (manual upload),
  x_fc_{nadcap,as9100,cgp}_logo + _active toggles for accreditation
  badges
- New res.config.settings section "Fusion Plating" exposing the above
  as configurable blocks; manager-only menu under Configuration →
  Fusion Plating Settings
- New fp.certificate fields: nc_quantity, customer_job_no,
  contact_partner_id (child contact for Name / Email / Phone block)
- New report_coc_en + report_coc_fr templates (primary): custom header
  (company contact | accreditations | company logo), bilingual labels
  per variant, customer info block with customer logo, 3-column cert
  info table, 6-column line-item table (Part # | Process | Customer
  PO | Shipped | NC Qty | Customer Job No.), signature image + bordered
  certification statement, footer "Fusion Plating by Nexa Systems"
- Legacy report_coc + report_coc_portrait kept for existing portal-job
  bindings (no behaviour change)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 01:18:22 -04:00

235 lines
12 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>
<button name="action_issue" string="Issue"
type="object" class="btn-primary"
invisible="state != 'draft'"/>
<button name="action_void" 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'"/>
<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>
<group>
<group>
<field name="certificate_type"/>
<field name="partner_id"/>
<field name="sale_order_id"/>
<field name="production_id"/>
<field name="portal_job_id"/>
<field name="issue_date"/>
</group>
<group>
<field name="part_number"/>
<field name="po_number"/>
<field name="entech_wo_number"/>
<field name="customer_job_no"/>
<field name="process_description"/>
<field name="spec_reference"/>
<field name="quantity_shipped"/>
<field name="nc_quantity"/>
<field name="contact_partner_id"
options="{'no_create': True}"
invisible="not partner_id"/>
</group>
</group>
<group>
<group>
<field name="issued_by_id"/>
<field name="certified_by_id"/>
</group>
<group>
<field name="reading_count" readonly="1"/>
<field name="mean_nip_mils" readonly="1"/>
</group>
</group>
<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"/>
<field name="std_dev_mils" readonly="1"/>
</group>
<group>
<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'"/>
<field name="trend_explanation" readonly="1"
invisible="trend_alert == 'ok'"/>
</group>
</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'">
<group>
<field name="void_reason"/>
</group>
</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>