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:
gsinghpal
2026-04-16 23:55:22 -04:00
parent d3dd6376a6
commit 6658544f85
30 changed files with 1098 additions and 15 deletions

View File

@@ -92,6 +92,7 @@ Copyright (c) 2026 Nexa Systems Inc. All rights reserved.
'views/fp_process_node_views.xml',
'views/fp_rack_views.xml',
'views/fp_bath_replenishment_views.xml',
'views/fp_operator_certification_views.xml',
'views/fp_menu.xml',
'data/fp_recipe_enp_alum_basic.xml',
],

View File

@@ -15,4 +15,5 @@ from . import fp_bath_parameter
from . import fp_bath_replenishment_rule
from . import fp_process_node
from . import fp_rack
from . import fp_operator_certification
from . import res_company

View File

@@ -144,8 +144,17 @@ class FpBathReplenishmentSuggestion(models.Model):
)
applied_at = fields.Datetime(readonly=True)
applied_by_id = fields.Many2one('res.users', readonly=True)
charged_to_mo_ref = fields.Char(
string='Charged to MO',
help='Manufacturing order this replenishment was charged against '
'(for job costing). Blank = unassigned.',
)
def action_apply(self):
"""Mark applied + log to bath chatter. A follow-up JobConsumption
record can be created by `action_apply_and_charge()` to attribute
cost to a specific MO.
"""
for rec in self:
rec.write({
'state': 'applied',

View File

@@ -0,0 +1,117 @@
# -*- 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 FpOperatorCertification(models.Model):
"""A signed-off training record that certifies an operator on a
specific process type.
Used to gate shop-floor work orders: an operator cannot start a
plating WO unless they hold a current (non-expired) certification
for that process.
"""
_name = 'fp.operator.certification'
_description = 'Fusion Plating — Operator Certification'
_inherit = ['mail.thread', 'mail.activity.mixin']
_order = 'employee_id, process_type_id'
name = fields.Char(
string='Certification Ref',
compute='_compute_name', store=True,
)
employee_id = fields.Many2one(
'hr.employee', string='Operator', required=True,
ondelete='cascade', tracking=True,
)
process_type_id = fields.Many2one(
'fusion.plating.process.type', string='Process Type',
required=True, ondelete='restrict', tracking=True,
)
issued_date = fields.Date(
string='Issued', default=fields.Date.today, required=True,
)
expires_date = fields.Date(
string='Expires',
help='Blank = no expiry. Set a date for re-certification tracking.',
)
issued_by_id = fields.Many2one(
'res.users', string='Certified By', default=lambda self: self.env.user,
)
training_record_attachment_id = fields.Many2one(
'ir.attachment', string='Training Record',
)
notes = fields.Text(string='Notes')
state = fields.Selection(
[('active', 'Active'),
('expired', 'Expired'),
('revoked', 'Revoked')],
string='Status', default='active', required=True,
compute='_compute_state', store=True, readonly=False, tracking=True,
)
revoked_reason = fields.Text(string='Revoked Reason')
_sql_constraints = [
('fp_operator_cert_unique',
'unique(employee_id, process_type_id, state)',
'An operator cannot hold two active certifications for the same process.'),
]
@api.depends('employee_id', 'process_type_id')
def _compute_name(self):
for rec in self:
if rec.employee_id and rec.process_type_id:
rec.name = f'{rec.employee_id.name} / {rec.process_type_id.name}'
else:
rec.name = ''
@api.depends('expires_date')
def _compute_state(self):
today = fields.Date.today()
for rec in self:
if rec.state == 'revoked':
continue
if rec.expires_date and rec.expires_date < today:
rec.state = 'expired'
elif rec.state != 'active':
rec.state = 'active'
def action_revoke(self):
for rec in self:
rec.state = 'revoked'
rec.message_post(body=_('Certification revoked.'))
@api.model
def has_active_cert(self, employee_id, process_type_id):
"""Utility — True if this employee holds a current certification
for this process type (or one of its ancestors in the category tree).
"""
if not employee_id or not process_type_id:
return False
return bool(self.search_count([
('employee_id', '=', employee_id),
('process_type_id', '=', process_type_id),
('state', '=', 'active'),
]))
class HrEmployee(models.Model):
_inherit = 'hr.employee'
x_fc_certification_ids = fields.One2many(
'fp.operator.certification', 'employee_id',
string='Plating Certifications',
)
x_fc_certified_process_ids = fields.Many2many(
'fusion.plating.process.type', compute='_compute_certified_processes',
string='Certified Processes',
)
@api.depends('x_fc_certification_ids.state', 'x_fc_certification_ids.process_type_id')
def _compute_certified_processes(self):
for emp in self:
active = emp.x_fc_certification_ids.filtered(lambda c: c.state == 'active')
emp.x_fc_certified_process_ids = active.mapped('process_type_id')

View File

@@ -39,6 +39,20 @@ class FpProcessType(models.Model):
required=True,
ondelete='restrict',
)
process_family = fields.Selection(
[('pre_treatment', 'Pre-Treatment'),
('plating', 'Plating'),
('post_treatment', 'Post-Treatment'),
('bake', 'Hydrogen Bake / Heat Treat'),
('strip', 'Strip'),
('passivation', 'Passivation'),
('masking', 'Masking / De-masking'),
('inspection', 'Inspection / QC')],
string='Family', default='plating', required=True, tracking=True,
help='High-level grouping used to filter baths and plan routings. '
'Pre-treatments (alkaline clean, acid etch, zincate) should be '
'tracked as full baths with their own chemistry logs.',
)
sequence = fields.Integer(
string='Sequence',
default=10,

View File

@@ -41,3 +41,6 @@ access_fp_replenishment_rule_manager,fp.replenishment.rule.manager,model_fusion_
access_fp_replenishment_suggestion_operator,fp.replenishment.suggestion.operator,model_fusion_plating_bath_replenishment_suggestion,group_fusion_plating_operator,1,1,1,0
access_fp_replenishment_suggestion_supervisor,fp.replenishment.suggestion.supervisor,model_fusion_plating_bath_replenishment_suggestion,group_fusion_plating_supervisor,1,1,1,0
access_fp_replenishment_suggestion_manager,fp.replenishment.suggestion.manager,model_fusion_plating_bath_replenishment_suggestion,group_fusion_plating_manager,1,1,1,1
access_fp_operator_cert_operator,fp.operator.cert.operator,model_fp_operator_certification,group_fusion_plating_operator,1,0,0,0
access_fp_operator_cert_supervisor,fp.operator.cert.supervisor,model_fp_operator_certification,group_fusion_plating_supervisor,1,1,1,0
access_fp_operator_cert_manager,fp.operator.cert.manager,model_fp_operator_certification,group_fusion_plating_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
41 access_fp_replenishment_suggestion_operator fp.replenishment.suggestion.operator model_fusion_plating_bath_replenishment_suggestion group_fusion_plating_operator 1 1 1 0
42 access_fp_replenishment_suggestion_supervisor fp.replenishment.suggestion.supervisor model_fusion_plating_bath_replenishment_suggestion group_fusion_plating_supervisor 1 1 1 0
43 access_fp_replenishment_suggestion_manager fp.replenishment.suggestion.manager model_fusion_plating_bath_replenishment_suggestion group_fusion_plating_manager 1 1 1 1
44 access_fp_operator_cert_operator fp.operator.cert.operator model_fp_operator_certification group_fusion_plating_operator 1 0 0 0
45 access_fp_operator_cert_supervisor fp.operator.cert.supervisor model_fp_operator_certification group_fusion_plating_supervisor 1 1 1 0
46 access_fp_operator_cert_manager fp.operator.cert.manager model_fp_operator_certification group_fusion_plating_manager 1 1 1 1

View File

@@ -172,6 +172,15 @@
<field name="process_type_id"/>
<field name="facility_id"/>
<separator/>
<filter string="Pre-Treatments" name="family_pre"
domain="[('process_type_id.process_family', '=', 'pre_treatment')]"/>
<filter string="Plating Baths" name="family_plating"
domain="[('process_type_id.process_family', '=', 'plating')]"/>
<filter string="Post-Treatments" name="family_post"
domain="[('process_type_id.process_family', '=', 'post_treatment')]"/>
<filter string="Strip Baths" name="family_strip"
domain="[('process_type_id.process_family', '=', 'strip')]"/>
<separator/>
<filter string="Operational" name="operational" domain="[('state','=','operational')]"/>
<filter string="Under Review" name="review" domain="[('state','=','under_review')]"/>
<filter string="Out of Spec" name="oos" domain="[('last_log_status','=','out_of_spec')]"/>

View File

@@ -61,6 +61,12 @@
action="action_fp_replenishment_rule"
sequence="55"/>
<menuitem id="menu_fp_operator_certifications"
name="Operator Certifications"
parent="menu_fp_config"
action="action_fp_operator_cert"
sequence="60"/>
<!-- ===== CONFIGURATION ===== -->
<menuitem id="menu_fp_config"
name="Configuration"

View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- ===== Certification List ===== -->
<record id="view_fp_operator_cert_list" model="ir.ui.view">
<field name="name">fp.operator.cert.list</field>
<field name="model">fp.operator.certification</field>
<field name="arch" type="xml">
<list decoration-success="state == 'active'"
decoration-danger="state == 'expired'"
decoration-muted="state == 'revoked'">
<field name="employee_id"/>
<field name="process_type_id"/>
<field name="issued_date"/>
<field name="expires_date"/>
<field name="issued_by_id" optional="show"/>
<field name="state" widget="badge"/>
</list>
</field>
</record>
<!-- ===== Certification Form ===== -->
<record id="view_fp_operator_cert_form" model="ir.ui.view">
<field name="name">fp.operator.cert.form</field>
<field name="model">fp.operator.certification</field>
<field name="arch" type="xml">
<form>
<header>
<button name="action_revoke" string="Revoke"
type="object" class="btn-danger"
invisible="state != 'active'"
confirm="Revoke this certification?"/>
<field name="state" widget="statusbar"/>
</header>
<sheet>
<div class="oe_title">
<h2><field name="name" readonly="1"/></h2>
</div>
<group>
<group>
<field name="employee_id"/>
<field name="process_type_id"/>
<field name="issued_by_id"/>
</group>
<group>
<field name="issued_date"/>
<field name="expires_date"/>
<field name="training_record_attachment_id"/>
</group>
</group>
<group string="Revocation" invisible="state != 'revoked'">
<field name="revoked_reason" nolabel="1" colspan="2"/>
</group>
<group string="Notes">
<field name="notes" nolabel="1" colspan="2"/>
</group>
</sheet>
<chatter/>
</form>
</field>
</record>
<!-- ===== Search ===== -->
<record id="view_fp_operator_cert_search" model="ir.ui.view">
<field name="name">fp.operator.cert.search</field>
<field name="model">fp.operator.certification</field>
<field name="arch" type="xml">
<search>
<field name="employee_id"/>
<field name="process_type_id"/>
<filter name="active" string="Active"
domain="[('state', '=', 'active')]"/>
<filter name="expired" string="Expired"
domain="[('state', '=', 'expired')]"/>
<filter name="expiring_soon" string="Expiring within 30 days"
domain="[('expires_date', '&lt;=', (context_today() + datetime.timedelta(days=30)).strftime('%Y-%m-%d')),
('expires_date', '&gt;=', context_today().strftime('%Y-%m-%d')),
('state', '=', 'active')]"/>
<separator/>
<group>
<filter name="group_employee" string="Operator"
context="{'group_by': 'employee_id'}"/>
<filter name="group_process" string="Process"
context="{'group_by': 'process_type_id'}"/>
<filter name="group_state" string="Status"
context="{'group_by': 'state'}"/>
</group>
</search>
</field>
</record>
<record id="action_fp_operator_cert" model="ir.actions.act_window">
<field name="name">Operator Certifications</field>
<field name="res_model">fp.operator.certification</field>
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="view_fp_operator_cert_search"/>
<field name="context">{'search_default_active': 1}</field>
</record>
<!-- Extend employee form with a smart list of certs -->
<record id="view_hr_employee_fp_certs" model="ir.ui.view">
<field name="name">hr.employee.form.fp.certs</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Plating Certifications" name="fp_certs">
<field name="x_fc_certification_ids"
context="{'default_employee_id': id}">
<list editable="bottom">
<field name="process_type_id"/>
<field name="issued_date"/>
<field name="expires_date"/>
<field name="state" widget="badge"/>
</list>
</field>
</page>
</xpath>
</field>
</record>
</odoo>

View File

@@ -67,7 +67,21 @@ class FpBatch(models.Model):
required=True,
tracking=True,
)
rack_ref = fields.Char(string='Rack / Barrel Ref')
rack_ref = fields.Char(string='Rack / Barrel Ref (legacy)')
rack_id = fields.Many2one(
'fusion.plating.rack', string='Rack / Fixture',
domain="[('state', '!=', 'retired')]",
tracking=True,
)
workorder_id = fields.Many2one(
'mrp.workorder', string='Work Order',
help='The WO this batch ran through. Used for material traceability.',
tracking=True,
)
production_id = fields.Many2one(
'mrp.production', string='Manufacturing Order',
related='workorder_id.production_id', store=True, readonly=True,
)
part_count = fields.Integer(string='Part Count')
start_time = fields.Datetime(string='Process Start', tracking=True)
end_time = fields.Datetime(string='Process End', tracking=True)

View File

@@ -56,6 +56,7 @@ Copyright (c) 2026 Nexa Systems Inc. All rights reserved.
'views/fp_quality_hold_views.xml',
'views/fp_batch_views.xml',
'views/fp_workorder_priority_views.xml',
'views/fp_job_consumption_views.xml',
],
'installable': True,
'application': False,

View File

@@ -12,4 +12,5 @@ from . import fp_quality_hold
from . import fp_delivery
from . import fp_batch
from . import fp_job_node_override
from . import fp_job_consumption
from . import account_move

View File

@@ -0,0 +1,84 @@
# -*- 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 FpJobConsumption(models.Model):
"""A single consumable drawdown charged to a manufacturing order.
Sources include bath replenishment applied against a job, masking tape
rolls, PPE, nickel salts — anything that has a cost and should roll
into job costing.
Kept deliberately lightweight: one row per event, cost derived from
`product.standard_price` at log time (snapshot, not reactive).
"""
_name = 'fp.job.consumption'
_description = 'Fusion Plating — Job Consumption'
_order = 'logged_date desc, id desc'
production_id = fields.Many2one(
'mrp.production', string='Manufacturing Order',
required=True, ondelete='cascade',
)
workorder_id = fields.Many2one(
'mrp.workorder', string='Work Order',
domain="[('production_id', '=', production_id)]",
)
product_id = fields.Many2one(
'product.product', string='Product', required=True,
domain="[('sale_ok', '=', False)]",
)
product_name = fields.Char(
string='Product Name (snapshot)',
help='Free-text product label if no inventory product is linked.',
)
quantity = fields.Float(string='Quantity', required=True, digits=(12, 3))
uom_id = fields.Many2one(
'uom.uom', string='UoM',
)
unit_cost = fields.Float(
string='Unit Cost (snapshot)', digits=(12, 4),
help='Taken from product.standard_price at log time.',
)
total_cost = fields.Float(
string='Total Cost', compute='_compute_total_cost', store=True, digits=(12, 2),
)
currency_id = fields.Many2one(
'res.currency', default=lambda self: self.env.company.currency_id,
)
logged_date = fields.Datetime(
string='Logged', default=fields.Datetime.now,
)
logged_by_id = fields.Many2one(
'res.users', string='Logged By', default=lambda self: self.env.user,
)
source = fields.Selection(
[('replenishment', 'Bath Replenishment'),
('masking', 'Masking Material'),
('ppe', 'PPE / Consumables'),
('chemistry', 'Process Chemistry'),
('other', 'Other')],
string='Source', default='other', required=True,
)
replenishment_id = fields.Many2one(
'fusion.plating.bath.replenishment.suggestion',
string='Replenishment Suggestion',
ondelete='set null',
)
notes = fields.Char(string='Notes')
@api.depends('quantity', 'unit_cost')
def _compute_total_cost(self):
for rec in self:
rec.total_cost = round((rec.quantity or 0) * (rec.unit_cost or 0), 2)
@api.onchange('product_id')
def _onchange_product(self):
if self.product_id:
self.product_name = self.product_id.display_name
self.unit_cost = self.product_id.standard_price or 0.0
self.uom_id = self.product_id.uom_id or False

View File

@@ -81,6 +81,98 @@ class MrpProduction(models.Model):
'or "Ready to Ship" when all work is done.',
)
# ------------------------------------------------------------------
# T3.3 — Actuals vs quoted margin
# T3.4 — Consumables tied to jobs
# ------------------------------------------------------------------
x_fc_consumption_ids = fields.One2many(
'fp.job.consumption', 'production_id',
string='Consumables Log',
)
x_fc_consumables_cost = fields.Monetary(
string='Consumables Cost', compute='_compute_job_costs',
store=True, currency_field='x_fc_currency_id',
)
x_fc_labour_cost = fields.Monetary(
string='Labour Cost', compute='_compute_job_costs',
store=True, currency_field='x_fc_currency_id',
help='Sum of WO duration × workcentre cost_hour, across all done WOs.',
)
x_fc_actual_cost = fields.Monetary(
string='Actual Total Cost', compute='_compute_job_costs',
store=True, currency_field='x_fc_currency_id',
)
x_fc_quoted_revenue = fields.Monetary(
string='Quoted Revenue', compute='_compute_job_costs',
store=True, currency_field='x_fc_currency_id',
help='Revenue from the originating sale order.',
)
x_fc_margin_actual = fields.Monetary(
string='Actual Margin ($)', compute='_compute_job_costs',
store=True, currency_field='x_fc_currency_id',
)
x_fc_margin_pct = fields.Float(
string='Actual Margin (%)', compute='_compute_job_costs',
store=True, digits=(6, 2),
)
x_fc_currency_id = fields.Many2one(
'res.currency', compute='_compute_job_costs', store=True,
)
x_fc_consumption_count = fields.Integer(
compute='_compute_consumption_count',
)
def _compute_consumption_count(self):
for mo in self:
mo.x_fc_consumption_count = len(mo.x_fc_consumption_ids)
@api.depends(
'x_fc_consumption_ids.total_cost',
'workorder_ids.duration',
'workorder_ids.workcenter_id.costs_hour',
'origin',
)
def _compute_job_costs(self):
SO = self.env['sale.order']
for mo in self:
currency = mo.company_id.currency_id
consumables = sum(mo.x_fc_consumption_ids.mapped('total_cost'))
labour = 0.0
for wo in mo.workorder_ids:
rate = wo.workcenter_id.costs_hour or 0.0
dur_hours = (wo.duration or 0.0) / 60.0
labour += dur_hours * rate
actual = consumables + labour
revenue = 0.0
if mo.origin:
so = SO.search([('name', '=', mo.origin)], limit=1)
if so:
revenue = so.amount_untaxed or 0.0
currency = so.currency_id or currency
margin = revenue - actual
pct = (margin / revenue * 100.0) if revenue else 0.0
mo.x_fc_consumables_cost = round(consumables, 2)
mo.x_fc_labour_cost = round(labour, 2)
mo.x_fc_actual_cost = round(actual, 2)
mo.x_fc_quoted_revenue = round(revenue, 2)
mo.x_fc_margin_actual = round(margin, 2)
mo.x_fc_margin_pct = round(pct, 2)
mo.x_fc_currency_id = currency
def action_view_consumption(self):
self.ensure_one()
return {
'type': 'ir.actions.act_window',
'name': _('Consumables — %s') % self.name,
'res_model': 'fp.job.consumption',
'view_mode': 'list,form',
'domain': [('production_id', '=', self.id)],
'context': {'default_production_id': self.id},
'target': 'current',
}
@api.depends('x_fc_override_ids')
def _compute_override_count(self):
for rec in self:

View File

@@ -403,6 +403,42 @@ class MrpWorkorder(models.Model):
})
return {'holds': holds, 'ncrs': ncrs}
# ------------------------------------------------------------------
# T2.2 — Certification gate on WO start
# ------------------------------------------------------------------
def button_start(self):
"""Block start unless the current user's linked employee holds
an active certification for this WO's process type."""
self._fp_check_operator_certification()
return super().button_start()
def _fp_check_operator_certification(self):
"""Raise UserError if the user isn't certified for this process."""
from odoo.exceptions import UserError
Cert = self.env.get('fp.operator.certification')
if Cert is None:
return
for wo in self:
# Figure out process_type: use bath's process if bath set,
# else workcenter's x_fc_facility_id.* — bath is the reliable one.
if not wo.x_fc_bath_id or not wo.x_fc_bath_id.process_type_id:
continue # Nothing to check
process_type = wo.x_fc_bath_id.process_type_id
employee = self.env.user.employee_id
if not employee:
# Admins without an employee record skip the check.
if not self.env.user.has_group('fusion_plating.group_fusion_plating_manager'):
raise UserError(_(
'You must be linked to an HR employee record to start '
'plating work orders. Contact your manager.'
))
return
if not Cert.has_active_cert(employee.id, process_type.id):
raise UserError(_(
'Operator %s is not certified for process "%s". '
'Request certification from your supervisor before starting this WO.'
) % (employee.name, process_type.name))
# ------------------------------------------------------------------
# T1.1 — Bake window auto-create on plating WO finish
# T1.3 — Rack MTO increment when a rack was used

View File

@@ -12,3 +12,6 @@ access_fp_recipe_config_wizard_supervisor,fp.recipe.config.wizard.supervisor,mod
access_fp_recipe_config_wizard_manager,fp.recipe.config.wizard.manager,model_fp_recipe_config_wizard,fusion_plating.group_fusion_plating_manager,1,1,1,1
access_fp_recipe_config_wizard_line_supervisor,fp.recipe.config.wizard.line.supervisor,model_fp_recipe_config_wizard_line,fusion_plating.group_fusion_plating_supervisor,1,1,1,0
access_fp_recipe_config_wizard_line_manager,fp.recipe.config.wizard.line.manager,model_fp_recipe_config_wizard_line,fusion_plating.group_fusion_plating_manager,1,1,1,1
access_fp_job_consumption_operator,fp.job.consumption.operator,model_fp_job_consumption,fusion_plating.group_fusion_plating_operator,1,1,1,0
access_fp_job_consumption_supervisor,fp.job.consumption.supervisor,model_fp_job_consumption,fusion_plating.group_fusion_plating_supervisor,1,1,1,0
access_fp_job_consumption_manager,fp.job.consumption.manager,model_fp_job_consumption,fusion_plating.group_fusion_plating_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
12 access_fp_recipe_config_wizard_manager fp.recipe.config.wizard.manager model_fp_recipe_config_wizard fusion_plating.group_fusion_plating_manager 1 1 1 1
13 access_fp_recipe_config_wizard_line_supervisor fp.recipe.config.wizard.line.supervisor model_fp_recipe_config_wizard_line fusion_plating.group_fusion_plating_supervisor 1 1 1 0
14 access_fp_recipe_config_wizard_line_manager fp.recipe.config.wizard.line.manager model_fp_recipe_config_wizard_line fusion_plating.group_fusion_plating_manager 1 1 1 1
15 access_fp_job_consumption_operator fp.job.consumption.operator model_fp_job_consumption fusion_plating.group_fusion_plating_operator 1 1 1 0
16 access_fp_job_consumption_supervisor fp.job.consumption.supervisor model_fp_job_consumption fusion_plating.group_fusion_plating_supervisor 1 1 1 0
17 access_fp_job_consumption_manager fp.job.consumption.manager model_fp_job_consumption fusion_plating.group_fusion_plating_manager 1 1 1 1

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_fp_job_consumption_list" model="ir.ui.view">
<field name="name">fp.job.consumption.list</field>
<field name="model">fp.job.consumption</field>
<field name="arch" type="xml">
<list editable="bottom" default_order="logged_date desc">
<field name="logged_date"/>
<field name="production_id"/>
<field name="workorder_id"/>
<field name="product_id"/>
<field name="quantity"/>
<field name="uom_id"/>
<field name="unit_cost"/>
<field name="total_cost" sum="Total"/>
<field name="source"/>
<field name="currency_id" invisible="1"/>
<field name="logged_by_id" optional="hide"/>
</list>
</field>
</record>
<record id="view_fp_job_consumption_form" model="ir.ui.view">
<field name="name">fp.job.consumption.form</field>
<field name="model">fp.job.consumption</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="production_id"/>
<field name="workorder_id"/>
<field name="product_id"/>
<field name="product_name"/>
<field name="source"/>
</group>
<group>
<field name="quantity"/>
<field name="uom_id"/>
<field name="unit_cost"/>
<field name="total_cost" readonly="1"/>
<field name="currency_id" invisible="1"/>
<field name="logged_date"/>
<field name="logged_by_id"/>
</group>
</group>
<group string="Notes">
<field name="notes" nolabel="1"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_fp_job_consumption" model="ir.actions.act_window">
<field name="name">Job Consumables Log</field>
<field name="res_model">fp.job.consumption</field>
<field name="view_mode">list,form</field>
</record>
</odoo>

View File

@@ -25,6 +25,27 @@
<field name="x_fc_recipe_id"/>
</group>
</group>
<group string="Job Costing" name="job_costing">
<field name="x_fc_currency_id" invisible="1"/>
<group>
<field name="x_fc_quoted_revenue" readonly="1"
widget="monetary"/>
<field name="x_fc_labour_cost" readonly="1"
widget="monetary"/>
<field name="x_fc_consumables_cost" readonly="1"
widget="monetary"/>
<field name="x_fc_actual_cost" readonly="1"
widget="monetary"/>
</group>
<group>
<field name="x_fc_margin_actual" readonly="1"
widget="monetary"
decoration-success="x_fc_margin_actual &gt; 0"
decoration-danger="x_fc_margin_actual &lt; 0"/>
<field name="x_fc_margin_pct" readonly="1"
widget="percentage"/>
</group>
</group>
<group string="Rework" name="rework"
invisible="not x_fc_is_rework and not x_fc_original_production_id">
<group>
@@ -58,6 +79,11 @@
<span class="o_stat_text">Create Rework</span>
</div>
</button>
<button name="action_view_consumption" type="object"
class="oe_stat_button" icon="fa-flask">
<field name="x_fc_consumption_count" widget="statinfo"
string="Consumables"/>
</button>
</xpath>
</field>

View File

@@ -5,7 +5,7 @@
{
'name': 'Fusion Plating — Certificates',
'version': '19.0.1.0.0',
'version': '19.0.2.0.0',
'category': 'Manufacturing/Plating',
'summary': 'Certificate registry for CoC, thickness reports, and quality documents.',
'description': """
@@ -25,6 +25,8 @@ Includes Fischerscope thickness measurement data capture.
'depends': [
'fusion_plating',
'fusion_plating_portal',
'fusion_plating_batch',
'fusion_plating_configurator',
'mrp',
'sale_management',
],

View File

@@ -56,6 +56,35 @@ class FpCertificate(models.Model):
thickness_reading_ids = fields.One2many(
'fp.thickness.reading', 'certificate_id', string='Thickness Readings',
)
# ---- Material traceability (T2.3) ----
batch_ids = fields.Many2many(
'fusion.plating.batch', compute='_compute_batch_ids',
string='Batches', help='All batches used for this MO.',
)
batch_count = fields.Integer(
string='Batches', compute='_compute_batch_ids',
)
bath_ids = fields.Many2many(
'fusion.plating.bath', compute='_compute_batch_ids',
string='Baths Used',
)
@api.depends('production_id')
def _compute_batch_ids(self):
Batch = self.env.get('fusion.plating.batch')
for rec in self:
if Batch is not None and rec.production_id:
batches = Batch.search([
('production_id', '=', rec.production_id.id),
])
rec.batch_ids = batches
rec.batch_count = len(batches)
rec.bath_ids = batches.mapped('bath_id')
else:
rec.batch_ids = False
rec.batch_count = 0
rec.bath_ids = False
state = fields.Selection(
[('draft', 'Draft'), ('issued', 'Issued'), ('voided', 'Voided')],
string='Status', default='draft', tracking=True, required=True,
@@ -65,29 +94,156 @@ class FpCertificate(models.Model):
# ----- Computed stats from readings -------------------------------------
reading_count = fields.Integer(
string='Readings', compute='_compute_reading_stats',
string='Readings', compute='_compute_reading_stats', store=True,
)
mean_nip_mils = fields.Float(
string='Mean NiP (mils)', compute='_compute_reading_stats', digits=(10, 4),
string='Mean NiP (mils)', compute='_compute_reading_stats',
store=True, digits=(10, 4),
)
@api.depends('thickness_reading_ids', 'thickness_reading_ids.nip_mils')
# ---- SPC (T2.1) ----
spec_min_mils = fields.Float(
string='Spec Min (mils)', digits=(10, 4),
help='Lower specification limit pulled from the coating config. '
'Override per certificate if needed.',
)
spec_max_mils = fields.Float(
string='Spec Max (mils)', digits=(10, 4),
help='Upper specification limit pulled from the coating config.',
)
std_dev_mils = fields.Float(
string='Std Dev (mils)', compute='_compute_reading_stats',
store=True, digits=(10, 4),
)
min_reading_mils = fields.Float(
string='Min Reading', compute='_compute_reading_stats',
store=True, digits=(10, 4),
)
max_reading_mils = fields.Float(
string='Max Reading', compute='_compute_reading_stats',
store=True, digits=(10, 4),
)
cpk = fields.Float(
string='Cpk', compute='_compute_reading_stats', store=True, digits=(6, 3),
help='Process capability index. <1.0 = incapable · 1.0-1.33 = marginal · '
'≥1.33 = capable · ≥1.67 = excellent.',
)
cpk_status = fields.Selection(
[('incapable', 'Incapable'),
('marginal', 'Marginal'),
('capable', 'Capable'),
('excellent', 'Excellent'),
('insufficient', 'Insufficient Data')],
string='Cpk Status', compute='_compute_reading_stats', store=True,
)
trend_alert = fields.Selection(
[('ok', 'OK'),
('warning', 'Trend Detected'),
('alert', 'Out of Control')],
string='Trend Alert', compute='_compute_reading_stats', store=True,
help='Western Electric rule 1 (any point beyond 3σ) or rule 4 '
'(8 consecutive points on one side of centre).',
)
trend_explanation = fields.Char(
string='Trend Note', compute='_compute_reading_stats', store=True,
)
@api.depends('thickness_reading_ids', 'thickness_reading_ids.nip_mils',
'spec_min_mils', 'spec_max_mils')
def _compute_reading_stats(self):
for rec in self:
readings = rec.thickness_reading_ids
rec.reading_count = len(readings)
if readings:
nip_values = readings.mapped('nip_mils')
rec.mean_nip_mils = sum(nip_values) / len(nip_values) if nip_values else 0
else:
rec.mean_nip_mils = 0
values = [r.nip_mils for r in readings if r.nip_mils]
n = len(values)
if n == 0:
rec.mean_nip_mils = 0.0
rec.std_dev_mils = 0.0
rec.min_reading_mils = 0.0
rec.max_reading_mils = 0.0
rec.cpk = 0.0
rec.cpk_status = 'insufficient'
rec.trend_alert = 'ok'
rec.trend_explanation = ''
continue
# ----- Sequence ---------------------------------------------------------
mean = sum(values) / n
rec.mean_nip_mils = round(mean, 4)
rec.min_reading_mils = round(min(values), 4)
rec.max_reading_mils = round(max(values), 4)
# Sample standard deviation (Bessel's correction)
if n >= 2:
sq_diff = sum((v - mean) ** 2 for v in values)
sigma = (sq_diff / (n - 1)) ** 0.5
else:
sigma = 0.0
rec.std_dev_mils = round(sigma, 4)
# Cpk — requires spec limits + non-zero sigma
usl = rec.spec_max_mils or 0.0
lsl = rec.spec_min_mils or 0.0
if n < 5 or sigma == 0 or (usl == 0 and lsl == 0):
rec.cpk = 0.0
rec.cpk_status = 'insufficient'
else:
if usl and lsl:
cpu = (usl - mean) / (3.0 * sigma)
cpl = (mean - lsl) / (3.0 * sigma)
cpk = min(cpu, cpl)
elif usl:
cpk = (usl - mean) / (3.0 * sigma)
else:
cpk = (mean - lsl) / (3.0 * sigma)
rec.cpk = round(cpk, 3)
if cpk < 1.0:
rec.cpk_status = 'incapable'
elif cpk < 1.33:
rec.cpk_status = 'marginal'
elif cpk < 1.67:
rec.cpk_status = 'capable'
else:
rec.cpk_status = 'excellent'
# Trend detection (Western Electric rules)
# Rule 1: any point outside 3σ from mean
# Rule 4: 8+ consecutive on one side of mean
alert = 'ok'
explanation = ''
if sigma > 0:
three_sigma = 3.0 * sigma
for v in values:
if abs(v - mean) > three_sigma:
alert = 'alert'
explanation = 'Rule 1: reading beyond 3σ from mean'
break
if alert == 'ok' and n >= 8:
# Check last 8 readings for all-above or all-below
last_eight = values[-8:]
if all(v > mean for v in last_eight):
alert = 'warning'
explanation = 'Rule 4: 8 consecutive readings above mean'
elif all(v < mean for v in last_eight):
alert = 'warning'
explanation = 'Rule 4: 8 consecutive readings below mean'
rec.trend_alert = alert
rec.trend_explanation = explanation
# ----- Sequence + spec-limit auto-fill ---------------------------------
@api.model_create_multi
def create(self, vals_list):
SaleOrder = self.env['sale.order']
for vals in vals_list:
if vals.get('name', 'New') == 'New':
vals['name'] = self.env['ir.sequence'].next_by_code('fp.certificate') or 'New'
# Pull thickness spec limits from coating config if not set
already_set = vals.get('spec_min_mils') or vals.get('spec_max_mils')
if not already_set and vals.get('sale_order_id'):
so = SaleOrder.browse(vals['sale_order_id'])
cfg = getattr(so, 'x_fc_coating_config_id', False)
if cfg and cfg.thickness_uom == 'mils':
vals.setdefault('spec_min_mils', cfg.thickness_min or 0.0)
vals.setdefault('spec_max_mils', cfg.thickness_max or 0.0)
return super().create(vals_list)
# ----- State actions ----------------------------------------------------
@@ -107,6 +263,19 @@ class FpCertificate(models.Model):
rec.state = 'voided'
rec.message_post(body=_('Certificate voided. Reason: %s') % rec.void_reason)
def action_view_traceability(self):
"""Show the batches (and their chemistry logs) that produced
these parts — auditor's dream, customer's RMA friend."""
self.ensure_one()
return {
'type': 'ir.actions.act_window',
'name': _('Traceability — %s') % self.name,
'res_model': 'fusion.plating.batch',
'view_mode': 'list,form',
'domain': [('id', 'in', self.batch_ids.ids)],
'target': 'current',
}
def action_send_to_customer(self):
"""Open email composer with the certificate PDF attached."""
self.ensure_one()

View File

@@ -52,6 +52,16 @@
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"/>
@@ -81,8 +91,31 @@
<field name="certified_by_id"/>
</group>
<group>
<field name="mean_nip_mils" readonly="1"/>
<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>

View File

@@ -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',

View File

@@ -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

View File

@@ -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]

View File

@@ -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)."""

View File

@@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
21 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
22 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
23 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
24 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
25 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
26 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

View File

@@ -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"

View File

@@ -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', '&lt;', 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>

View File

@@ -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">

View File

@@ -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()