feat(fusion_plating): Tier 2 (quality + audit) and Tier 3 (business) features
Tier 2 — Quality & audit readiness:
- T2.1 SPC on thickness readings (fp.certificate)
- spec_min_mils / spec_max_mils auto-pulled from coating config on create
- Computed: std_dev_mils, min/max, cpk, cpk_status (incapable/marginal/
capable/excellent/insufficient)
- Western Electric trend rules (rule 1: any point beyond 3σ; rule 4:
8 consecutive on one side of mean) → trend_alert + explanation
- New SPC group on certificate form with badge-coloured indicators
- T2.2 Operator certification enforcement (fp.operator.certification)
- Per (employee, process_type) records with issued/expires dates,
training record attachment, revocation workflow
- State auto-computed: active → expired when date passes
- MrpWorkorder.button_start() blocks with UserError if current user's
linked hr.employee lacks an active cert for the bath's process_type
- Managers bypass the check; expiring-soon filter in search view
- HR Employee form: "Plating Certifications" tab
- T2.3 Material traceability chain
- fusion.plating.batch.workorder_id (new Many2one) + production_id
(related through WO) for full chain
- fp.certificate gets computed batch_ids / bath_ids / batch_count
- "Batches" stat button → list of batches used for this cert's MO,
with their chemistry logs intact
- T2.4 Pre-treatment as first-class baths
- process_family selection on fusion.plating.process.type
(pre_treatment / plating / post_treatment / bake / strip / passivation /
masking / inspection)
- Bath search view: Pre-Treatments / Plating / Post-Treatments / Strip
quick filters
- Existing bath infra (logs, replenishment, SPC) now applies to pre-
treatment baths equally
Tier 3 — Business / revenue:
- T3.1 Customer-specific price lists (fp.customer.price.list)
- Per (customer, coating_config) with unit_price + basis (per_part /
sqin / sqft / lb)
- effective_from / effective_to for annual contract pricing
- min_quantity for volume breaks (cheapest price at requested qty wins)
- _find_price() helper resolves active entry by date + qty
- Direct Order wizard auto-fills unit_price on (partner, coating, qty)
change unless operator has typed an override
- Configurator menu → Customer Price Lists
- T3.2 Quote win/loss tracking (fp.quote.configurator)
- State values: draft → confirmed (won) / lost / expired / cancelled
- lost_reason selection (price / lead_time / tech / spec_mismatch /
no_bid / no_response / competitor / other) + lost_competitor_name
+ lost_details text
- Action buttons: Mark as Lost (requires reason), Mark as Expired
- won_date auto-set on SO creation; lost_date auto-set on mark_lost
- New "Win / Loss" tab on configurator form
- T3.3 Actuals vs. quoted margin (mrp.production)
- Computed monetary fields: x_fc_consumables_cost, x_fc_labour_cost,
x_fc_actual_cost, x_fc_quoted_revenue, x_fc_margin_actual,
x_fc_margin_pct
- Labour = sum(WO duration × workcentre cost_hour)
- Revenue = SO amount_untaxed via mo.origin lookup
- New "Job Costing" group on MO form with badge-coloured margin
- T3.4 Job consumables tracking (fp.job.consumption)
- One row per consumable event (bath replenisher, masking tape, PPE,
chemistry): product, qty, uom, unit_cost (snapshot), total_cost,
source, optional workorder link
- One2many x_fc_consumption_ids on mrp.production
- "Consumables" stat button on MO → filtered list
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,7 @@ Provides:
|
||||
'views/fp_part_catalog_views.xml',
|
||||
'views/fp_coating_config_views.xml',
|
||||
'views/fp_pricing_rule_views.xml',
|
||||
'views/fp_customer_price_list_views.xml',
|
||||
'views/fp_quote_configurator_views.xml',
|
||||
'views/sale_order_views.xml',
|
||||
'views/res_partner_views.xml',
|
||||
|
||||
@@ -8,6 +8,7 @@ from . import fp_part_catalog
|
||||
from . import fp_coating_config
|
||||
from . import fp_pricing_complexity_surcharge
|
||||
from . import fp_pricing_rule
|
||||
from . import fp_customer_price_list
|
||||
from . import fp_quote_configurator
|
||||
from . import sale_order
|
||||
from . import res_partner
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class FpCustomerPriceList(models.Model):
|
||||
"""Standing price per (customer, coating config).
|
||||
|
||||
Repeat customers accept a negotiated price per coating — the configurator
|
||||
and Direct Order wizard auto-fill `unit_price` from here before falling
|
||||
back to the formula-based pricing engine.
|
||||
|
||||
Optional effective_from / effective_to support annual contracts.
|
||||
"""
|
||||
_name = 'fp.customer.price.list'
|
||||
_description = 'Fusion Plating — Customer Price List'
|
||||
_inherit = ['mail.thread']
|
||||
_order = 'partner_id, coating_config_id, effective_from desc'
|
||||
|
||||
name = fields.Char(
|
||||
string='Reference', compute='_compute_name', store=True,
|
||||
)
|
||||
partner_id = fields.Many2one(
|
||||
'res.partner', string='Customer', required=True, ondelete='cascade',
|
||||
tracking=True, domain="[('customer_rank', '>', 0)]",
|
||||
)
|
||||
coating_config_id = fields.Many2one(
|
||||
'fp.coating.config', string='Coating', required=True, ondelete='restrict',
|
||||
tracking=True,
|
||||
)
|
||||
unit_price = fields.Float(
|
||||
string='Unit Price', required=True, digits=(12, 4), tracking=True,
|
||||
)
|
||||
price_uom = fields.Selection(
|
||||
[('per_part', 'per Part'),
|
||||
('per_sqin', 'per sq in'),
|
||||
('per_sqft', 'per sq ft'),
|
||||
('per_lb', 'per lb')],
|
||||
string='Price Basis', default='per_part', required=True,
|
||||
)
|
||||
currency_id = fields.Many2one(
|
||||
'res.currency', string='Currency',
|
||||
default=lambda self: self.env.company.currency_id,
|
||||
)
|
||||
effective_from = fields.Date(
|
||||
string='Effective From', default=fields.Date.today, required=True, tracking=True,
|
||||
)
|
||||
effective_to = fields.Date(
|
||||
string='Effective To',
|
||||
help='Blank = no expiry. Set for annual contract pricing.',
|
||||
tracking=True,
|
||||
)
|
||||
min_quantity = fields.Integer(
|
||||
string='Minimum Qty', default=1,
|
||||
help='Volume break — this price applies for orders of this size or larger.',
|
||||
)
|
||||
notes = fields.Html(string='Notes')
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
_sql_constraints = [
|
||||
('fp_price_list_unique',
|
||||
'unique(partner_id, coating_config_id, effective_from, min_quantity)',
|
||||
'A price entry already exists for this customer + coating + '
|
||||
'effective date + quantity tier.'),
|
||||
]
|
||||
|
||||
@api.depends('partner_id', 'coating_config_id', 'min_quantity', 'effective_from')
|
||||
def _compute_name(self):
|
||||
for rec in self:
|
||||
parts = []
|
||||
if rec.partner_id:
|
||||
parts.append(rec.partner_id.name)
|
||||
if rec.coating_config_id:
|
||||
parts.append(rec.coating_config_id.name)
|
||||
if rec.min_quantity > 1:
|
||||
parts.append(f'≥{rec.min_quantity}')
|
||||
rec.name = ' / '.join(parts) if parts else ''
|
||||
|
||||
@api.model
|
||||
def _find_price(self, partner_id, coating_config_id, quantity=1, on_date=None):
|
||||
"""Return the best-matching active price list entry for this request."""
|
||||
if not (partner_id and coating_config_id):
|
||||
return False
|
||||
on_date = on_date or fields.Date.today()
|
||||
candidates = self.search([
|
||||
('partner_id', '=', partner_id),
|
||||
('coating_config_id', '=', coating_config_id),
|
||||
('active', '=', True),
|
||||
('effective_from', '<=', on_date),
|
||||
'|', ('effective_to', '=', False), ('effective_to', '>=', on_date),
|
||||
('min_quantity', '<=', quantity),
|
||||
], order='min_quantity desc, effective_from desc')
|
||||
return candidates[:1]
|
||||
@@ -23,9 +23,30 @@ class FpQuoteConfigurator(models.Model):
|
||||
|
||||
name = fields.Char(string='Reference', readonly=True, copy=False, default='New')
|
||||
state = fields.Selection(
|
||||
[('draft', 'Draft'), ('confirmed', 'Confirmed'), ('cancelled', 'Cancelled')],
|
||||
[('draft', 'Draft'),
|
||||
('confirmed', 'Won (SO Created)'),
|
||||
('lost', 'Lost'),
|
||||
('expired', 'Expired'),
|
||||
('cancelled', 'Cancelled')],
|
||||
string='Status', default='draft', tracking=True,
|
||||
)
|
||||
|
||||
# ---- Win/Loss tracking (T3.2) ----
|
||||
lost_reason = fields.Selection(
|
||||
[('price', 'Price'),
|
||||
('lead_time', 'Lead Time'),
|
||||
('tech_capability', 'Technical Capability'),
|
||||
('spec_mismatch', 'Spec / Certification Mismatch'),
|
||||
('no_bid', 'No-Bid'),
|
||||
('no_response', 'Customer No-Response'),
|
||||
('competitor', 'Lost to Competitor'),
|
||||
('other', 'Other')],
|
||||
string='Lost Reason', tracking=True,
|
||||
)
|
||||
lost_competitor_name = fields.Char(string='Competitor', tracking=True)
|
||||
lost_details = fields.Text(string='Loss Notes')
|
||||
won_date = fields.Date(string='Won Date', readonly=True)
|
||||
lost_date = fields.Date(string='Lost Date', readonly=True)
|
||||
partner_id = fields.Many2one(
|
||||
'res.partner', string='Customer', required=True,
|
||||
domain="[('customer_rank', '>', 0)]",
|
||||
@@ -520,6 +541,7 @@ class FpQuoteConfigurator(models.Model):
|
||||
self.write({
|
||||
'sale_order_id': so.id,
|
||||
'state': 'confirmed',
|
||||
'won_date': fields.Date.today(),
|
||||
})
|
||||
self.message_post(
|
||||
body=_('Sale Order <a href="/odoo/sale-order/%s">%s</a> created.') % (so.id, so.name),
|
||||
@@ -732,7 +754,30 @@ class FpQuoteConfigurator(models.Model):
|
||||
self.write({'state': 'cancelled'})
|
||||
|
||||
def action_reset_draft(self):
|
||||
self.write({'state': 'draft'})
|
||||
self.write({'state': 'draft', 'won_date': False, 'lost_date': False})
|
||||
|
||||
def action_mark_lost(self):
|
||||
"""Move this quote to 'lost' state. Caller should populate
|
||||
`lost_reason` first — a simple validation enforces that."""
|
||||
for rec in self:
|
||||
if not rec.lost_reason:
|
||||
from odoo.exceptions import UserError
|
||||
raise UserError(_(
|
||||
'Please set a Lost Reason before marking this quote lost.'
|
||||
))
|
||||
rec.write({
|
||||
'state': 'lost',
|
||||
'lost_date': fields.Date.today(),
|
||||
})
|
||||
rec.message_post(
|
||||
body=_('Quote marked lost — reason: %s') % dict(
|
||||
rec._fields['lost_reason'].selection
|
||||
).get(rec.lost_reason, rec.lost_reason),
|
||||
)
|
||||
|
||||
def action_mark_expired(self):
|
||||
for rec in self:
|
||||
rec.write({'state': 'expired', 'lost_date': fields.Date.today()})
|
||||
|
||||
def action_open_3d_fullscreen(self):
|
||||
"""Open the 3D model viewer in a full-screen dialog (same window)."""
|
||||
|
||||
@@ -21,3 +21,6 @@ access_fp_direct_order_wizard_estimator,fp.direct.order.wizard.estimator,model_f
|
||||
access_fp_direct_order_wizard_manager,fp.direct.order.wizard.manager,model_fp_direct_order_wizard,fusion_plating.group_fusion_plating_manager,1,1,1,1
|
||||
access_fp_part_import_wizard_estimator,fp.part.catalog.import.wizard.estimator,model_fp_part_catalog_import_wizard,fusion_plating_configurator.group_fp_estimator,1,1,1,1
|
||||
access_fp_part_import_wizard_manager,fp.part.catalog.import.wizard.manager,model_fp_part_catalog_import_wizard,fusion_plating.group_fusion_plating_manager,1,1,1,1
|
||||
access_fp_customer_price_list_operator,fp.customer.price.list.operator,model_fp_customer_price_list,fusion_plating.group_fusion_plating_operator,1,0,0,0
|
||||
access_fp_customer_price_list_estimator,fp.customer.price.list.estimator,model_fp_customer_price_list,fusion_plating_configurator.group_fp_estimator,1,1,1,0
|
||||
access_fp_customer_price_list_manager,fp.customer.price.list.manager,model_fp_customer_price_list,fusion_plating.group_fusion_plating_manager,1,1,1,1
|
||||
|
||||
|
@@ -83,6 +83,12 @@
|
||||
action="action_fp_pricing_rule"
|
||||
sequence="30"/>
|
||||
|
||||
<menuitem id="menu_fp_customer_price_lists"
|
||||
name="Customer Price Lists"
|
||||
parent="menu_fp_configurator"
|
||||
action="action_fp_customer_price_list"
|
||||
sequence="35"/>
|
||||
|
||||
<menuitem id="menu_fp_treatments"
|
||||
name="Treatments"
|
||||
parent="menu_fp_configurator"
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_fp_customer_price_list_list" model="ir.ui.view">
|
||||
<field name="name">fp.customer.price.list.list</field>
|
||||
<field name="model">fp.customer.price.list</field>
|
||||
<field name="arch" type="xml">
|
||||
<list editable="bottom">
|
||||
<field name="partner_id"/>
|
||||
<field name="coating_config_id"/>
|
||||
<field name="unit_price"/>
|
||||
<field name="price_uom"/>
|
||||
<field name="currency_id" optional="hide"/>
|
||||
<field name="min_quantity"/>
|
||||
<field name="effective_from"/>
|
||||
<field name="effective_to"/>
|
||||
<field name="active" widget="boolean_toggle"/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_fp_customer_price_list_form" model="ir.ui.view">
|
||||
<field name="name">fp.customer.price.list.form</field>
|
||||
<field name="model">fp.customer.price.list</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h2><field name="name" readonly="1"/></h2>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="partner_id"/>
|
||||
<field name="coating_config_id"/>
|
||||
<field name="unit_price"/>
|
||||
<field name="price_uom"/>
|
||||
<field name="currency_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="effective_from"/>
|
||||
<field name="effective_to"/>
|
||||
<field name="min_quantity"/>
|
||||
<field name="active" widget="boolean_toggle"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="Notes">
|
||||
<field name="notes" nolabel="1" colspan="2"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<chatter/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_fp_customer_price_list_search" model="ir.ui.view">
|
||||
<field name="name">fp.customer.price.list.search</field>
|
||||
<field name="model">fp.customer.price.list</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="partner_id"/>
|
||||
<field name="coating_config_id"/>
|
||||
<filter name="active" string="Active"
|
||||
domain="[('active', '=', True)]"/>
|
||||
<filter name="expired" string="Expired"
|
||||
domain="[('effective_to', '<', context_today().strftime('%Y-%m-%d'))]"/>
|
||||
<separator/>
|
||||
<group>
|
||||
<filter name="group_customer" string="Customer"
|
||||
context="{'group_by': 'partner_id'}"/>
|
||||
<filter name="group_coating" string="Coating"
|
||||
context="{'group_by': 'coating_config_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_fp_customer_price_list" model="ir.actions.act_window">
|
||||
<field name="name">Customer Price Lists</field>
|
||||
<field name="res_model">fp.customer.price.list</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
<field name="search_view_id" ref="view_fp_customer_price_list_search"/>
|
||||
<field name="context">{'search_default_active': 1}</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -29,6 +29,16 @@
|
||||
class="btn-secondary"
|
||||
confirm="This will overwrite the part catalog's geometry, substrate, masking area, and complexity with values from this quote. Continue?"
|
||||
invisible="not part_catalog_id"/>
|
||||
<button name="action_mark_lost"
|
||||
string="Mark as Lost"
|
||||
type="object"
|
||||
class="btn-warning"
|
||||
invisible="state != 'draft'"
|
||||
confirm="Mark this quote as Lost? Set the Lost Reason first."/>
|
||||
<button name="action_mark_expired"
|
||||
string="Mark as Expired"
|
||||
type="object"
|
||||
invisible="state != 'draft'"/>
|
||||
<button name="action_cancel"
|
||||
string="Cancel"
|
||||
type="object"
|
||||
@@ -37,7 +47,8 @@
|
||||
string="Reset to Draft"
|
||||
type="object"
|
||||
invisible="state == 'draft'"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,confirmed,cancelled"/>
|
||||
<field name="state" widget="statusbar"
|
||||
statusbar_visible="draft,confirmed,lost,expired,cancelled"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
@@ -244,6 +255,21 @@
|
||||
<page string="Sale Order" name="sale_order">
|
||||
<group>
|
||||
<field name="sale_order_id" readonly="1"/>
|
||||
<field name="won_date" readonly="1"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Win / Loss" name="win_loss">
|
||||
<group>
|
||||
<group>
|
||||
<field name="lost_reason"/>
|
||||
<field name="lost_competitor_name"
|
||||
invisible="lost_reason != 'competitor'"/>
|
||||
<field name="lost_date" readonly="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="Notes">
|
||||
<field name="lost_details" nolabel="1" colspan="2"
|
||||
placeholder="What did we learn? (Price point competitor beat, spec we didn't meet, etc.)"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Notes" name="notes">
|
||||
|
||||
@@ -91,6 +91,21 @@ class FpDirectOrderWizard(models.TransientModel):
|
||||
self.invoice_strategy = self.partner_id.x_fc_default_invoice_strategy or False
|
||||
self.deposit_percent = self.partner_id.x_fc_default_deposit_percent or 0.0
|
||||
|
||||
@api.onchange('coating_config_id', 'quantity', 'partner_id')
|
||||
def _onchange_lookup_price(self):
|
||||
"""Auto-fill unit_price from customer price list when available."""
|
||||
if not (self.partner_id and self.coating_config_id):
|
||||
return
|
||||
# Don't overwrite a manually-entered price
|
||||
if self.unit_price:
|
||||
return
|
||||
price = self.env['fp.customer.price.list']._find_price(
|
||||
self.partner_id.id, self.coating_config_id.id,
|
||||
quantity=self.quantity or 1,
|
||||
)
|
||||
if price:
|
||||
self.unit_price = price.unit_price
|
||||
|
||||
def action_create_order(self):
|
||||
"""Create and confirm the sale order, optionally bumping part revision."""
|
||||
self.ensure_one()
|
||||
|
||||
Reference in New Issue
Block a user