feat(fusion_plating): quote-to-cash infra, notifications, wizards, Tier 1 plating features
Quote-to-cash PDF reports (portrait + landscape variants, 16 new actions): - Quotation / Sales Order, Work Order Traveller, Packing Slip, Bill of Lading, Certificate of Conformance (portrait added), Invoice, Payment Receipt - Shared fp_portrait_styles + fp_landscape_styles base templates Workflow gap fixes (fusion_plating_bridge_mrp): - Auto-assign recipe from SO coating config in MrpProduction.action_confirm - Auto-create draft CoC (fp.certificate) on MrpProduction.button_mark_done Notifications overhaul (fusion_plating_notifications v2.0): - Expanded TRIGGER_EVENTS to 7 (added quote_sent, mo_complete, shipped, payment_received) - Shared _dispatch method replaces three duplicated send helpers - Auto-attach PDF reports per template config (quote, SO, CoC, invoice, receipt, BoL) - Rebuilt 7 email templates with fusion_claims accent-bar design (info/success color-coded, theme-safe, 600px max-width) - New hooks: MrpProduction done, FpDelivery mark_delivered, AccountPayment post, SaleOrder action_quotation_send Wizards (fusion_plating_configurator): - fp.direct.order.wizard — skip quotation for repeat customers with PO in hand; optional new-revision drawing upload bumps fp.part.catalog revision and links new rev to the SO; creates + confirms the SO in one step - fp.part.catalog.import.wizard — 3-step CSV import with dry-run preview, tolerant parsing (customer by name/email/xmlid, human-readable selections), duplicate detection, create-missing-customers option, single transaction commit - Partner form stat buttons: Direct Order, Import Parts - CSV template download button Tier 1 practical plating features: - T1.1 Hydrogen bake window enforcement (fp.coating.config.requires_bake_relief, auto-create fusion.plating.bake.window on plating WO finish, FpDelivery lockout when window is open) - T1.2 Bath replenishment rules + pending suggestion queue (fusion.plating.bath.replenishment.rule + .suggestion, hook on bath log line create, operator Apply / Dismiss actions) - T1.3 Rack/fixture library (fusion.plating.rack with MTO counter, strip schedule, lifecycle: active → needs_strip → stripping → retired) - T1.4 Rework / strip-and-replate MOs (x_fc_is_rework, x_fc_original_production_id, Create Rework stat button on completed MOs) - T1.5 Parts location (x_fc_current_location computed on mrp.production — "In progress: Alkaline Clean" / "Queued: Bake Oven" / "Ready to Ship") Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,5 +12,7 @@ from . import fp_bath
|
||||
from . import fp_bath_log
|
||||
from . import fp_bath_log_line
|
||||
from . import fp_bath_parameter
|
||||
from . import fp_bath_replenishment_rule
|
||||
from . import fp_process_node
|
||||
from . import fp_rack
|
||||
from . import res_company
|
||||
|
||||
@@ -112,3 +112,47 @@ class FpBathLogLine(models.Model):
|
||||
rec.status = 'warning'
|
||||
else:
|
||||
rec.status = 'ok'
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# T1.2 — Auto-suggest replenishment on every log line
|
||||
# ------------------------------------------------------------------
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
lines = super().create(vals_list)
|
||||
lines._spawn_replenishment_suggestions()
|
||||
return lines
|
||||
|
||||
def _spawn_replenishment_suggestions(self):
|
||||
"""For every out-of-spec reading, run the matching replenishment
|
||||
rule and create a pending suggestion the operator can apply."""
|
||||
Rule = self.env['fusion.plating.bath.replenishment.rule']
|
||||
Suggestion = self.env['fusion.plating.bath.replenishment.suggestion']
|
||||
for line in self:
|
||||
if not line.parameter_id or not line.log_id.bath_id:
|
||||
continue
|
||||
bath = line.log_id.bath_id
|
||||
rules = Rule._find_rules(bath, line.parameter_id.id)
|
||||
for rule in rules:
|
||||
dose = rule._compute_dose(
|
||||
line.value, line.target_min, line.target_max, bath.volume,
|
||||
)
|
||||
if dose <= 0:
|
||||
continue
|
||||
Suggestion.create({
|
||||
'bath_id': bath.id,
|
||||
'log_line_id': line.id,
|
||||
'rule_id': rule.id,
|
||||
'parameter_id': line.parameter_id.id,
|
||||
'current_value': line.value,
|
||||
'target_min': line.target_min,
|
||||
'target_max': line.target_max,
|
||||
'product_name': rule.product_name,
|
||||
'dose_amount': dose,
|
||||
'dose_uom': rule.dose_uom,
|
||||
'state': 'pending',
|
||||
})
|
||||
bath.message_post(
|
||||
body=f'Replenishment suggested: add {dose} {rule.dose_uom} '
|
||||
f'of {rule.product_name} ({line.parameter_id.name} '
|
||||
f'reading: {line.value})',
|
||||
)
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
# -*- 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 FpBathReplenishmentRule(models.Model):
|
||||
"""Linear replenishment rule: when a chemistry reading drifts outside
|
||||
target, calculate how much replenisher to add.
|
||||
|
||||
The formula is deliberately simple:
|
||||
dose = deficit × bath.volume × dose_rate
|
||||
|
||||
where deficit = (target_min − value) for below_min rules
|
||||
or = (value − target_max) for above_max rules.
|
||||
|
||||
Shops wanting non-linear or piecewise rules can extend this model.
|
||||
"""
|
||||
_name = 'fusion.plating.bath.replenishment.rule'
|
||||
_description = 'Fusion Plating — Replenishment Rule'
|
||||
_order = 'process_type_id, parameter_id'
|
||||
|
||||
name = fields.Char(string='Rule Name', required=True)
|
||||
process_type_id = fields.Many2one(
|
||||
'fusion.plating.process.type', string='Process Type',
|
||||
help='If set, this rule applies to every bath running this process. '
|
||||
'Leave blank and set bath_id for a bath-specific rule.',
|
||||
)
|
||||
bath_id = fields.Many2one(
|
||||
'fusion.plating.bath', string='Specific Bath',
|
||||
help='Narrow the rule to a single bath (overrides process-level rule).',
|
||||
)
|
||||
parameter_id = fields.Many2one(
|
||||
'fusion.plating.bath.parameter', string='Parameter', required=True,
|
||||
)
|
||||
trigger = fields.Selection(
|
||||
[('below_min', 'Reading Below Target Min'),
|
||||
('above_max', 'Reading Above Target Max')],
|
||||
string='Trigger', required=True, default='below_min',
|
||||
)
|
||||
product_name = fields.Char(
|
||||
string='Replenisher Name', required=True,
|
||||
help='Human-readable chemical name, e.g. "Nickel Sulfamate 30% — Grade A"',
|
||||
)
|
||||
product_id = fields.Many2one(
|
||||
'product.product', string='Product (Inventory)',
|
||||
help='Optional link to an inventory product for consumption tracking.',
|
||||
)
|
||||
dose_rate = fields.Float(
|
||||
string='Dose Rate', required=True, digits=(12, 4),
|
||||
help='Amount of replenisher per unit of parameter deficit per gallon '
|
||||
'of bath volume. E.g. 0.5 means "add 0.5 mL per (g/L deficit) per gallon".',
|
||||
)
|
||||
dose_uom = fields.Selection(
|
||||
[('ml', 'mL'), ('oz', 'fl oz'), ('g', 'g'), ('lb', 'lb'), ('l', 'L')],
|
||||
string='Dose UoM', required=True, default='ml',
|
||||
)
|
||||
min_dose = fields.Float(
|
||||
string='Minimum Dose', default=0.0,
|
||||
help='Do not suggest doses below this (useful to avoid noise).',
|
||||
)
|
||||
max_dose = fields.Float(
|
||||
string='Safety Cap', default=0.0,
|
||||
help='Cap the suggested dose. 0 = no cap.',
|
||||
)
|
||||
notes = fields.Text(string='Operator Notes')
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
@api.model
|
||||
def _find_rules(self, bath, parameter_id):
|
||||
"""Return rules applicable to this (bath, parameter). Bath-specific
|
||||
rules take precedence over process-level ones.
|
||||
"""
|
||||
bath_rule = self.search([
|
||||
('bath_id', '=', bath.id),
|
||||
('parameter_id', '=', parameter_id),
|
||||
('active', '=', True),
|
||||
])
|
||||
if bath_rule:
|
||||
return bath_rule
|
||||
return self.search([
|
||||
('bath_id', '=', False),
|
||||
('process_type_id', '=', bath.process_type_id.id),
|
||||
('parameter_id', '=', parameter_id),
|
||||
('active', '=', True),
|
||||
])
|
||||
|
||||
def _compute_dose(self, value, target_min, target_max, bath_volume):
|
||||
"""Return a dose amount for this rule given the reading context.
|
||||
Returns 0.0 if the trigger doesn't apply.
|
||||
"""
|
||||
self.ensure_one()
|
||||
deficit = 0.0
|
||||
if self.trigger == 'below_min' and target_min and value < target_min:
|
||||
deficit = target_min - value
|
||||
elif self.trigger == 'above_max' and target_max and value > target_max:
|
||||
deficit = value - target_max
|
||||
if deficit <= 0:
|
||||
return 0.0
|
||||
dose = deficit * (bath_volume or 1.0) * self.dose_rate
|
||||
if self.min_dose and dose < self.min_dose:
|
||||
return 0.0
|
||||
if self.max_dose and dose > self.max_dose:
|
||||
dose = self.max_dose
|
||||
return round(dose, 3)
|
||||
|
||||
|
||||
class FpBathReplenishmentSuggestion(models.Model):
|
||||
"""One suggestion generated from a bath-log reading. Operators mark
|
||||
them applied or dismissed once the dose has been added."""
|
||||
_name = 'fusion.plating.bath.replenishment.suggestion'
|
||||
_description = 'Fusion Plating — Replenishment Suggestion'
|
||||
_inherit = ['mail.thread']
|
||||
_order = 'create_date desc, id desc'
|
||||
|
||||
bath_id = fields.Many2one(
|
||||
'fusion.plating.bath', string='Bath', required=True, ondelete='cascade',
|
||||
)
|
||||
log_line_id = fields.Many2one(
|
||||
'fusion.plating.bath.log.line', string='Triggering Reading',
|
||||
ondelete='cascade',
|
||||
)
|
||||
rule_id = fields.Many2one(
|
||||
'fusion.plating.bath.replenishment.rule', string='Rule',
|
||||
ondelete='set null',
|
||||
)
|
||||
parameter_id = fields.Many2one(
|
||||
'fusion.plating.bath.parameter', string='Parameter', required=True,
|
||||
)
|
||||
current_value = fields.Float(string='Current Reading', digits=(12, 4))
|
||||
target_min = fields.Float(string='Target Min', digits=(12, 4))
|
||||
target_max = fields.Float(string='Target Max', digits=(12, 4))
|
||||
product_name = fields.Char(string='Replenisher', required=True)
|
||||
dose_amount = fields.Float(string='Suggested Dose', digits=(12, 3))
|
||||
dose_uom = fields.Selection(
|
||||
[('ml', 'mL'), ('oz', 'fl oz'), ('g', 'g'), ('lb', 'lb'), ('l', 'L')],
|
||||
string='UoM', required=True, default='ml',
|
||||
)
|
||||
state = fields.Selection(
|
||||
[('pending', 'Pending'), ('applied', 'Applied'), ('dismissed', 'Dismissed')],
|
||||
default='pending', tracking=True,
|
||||
)
|
||||
applied_at = fields.Datetime(readonly=True)
|
||||
applied_by_id = fields.Many2one('res.users', readonly=True)
|
||||
|
||||
def action_apply(self):
|
||||
for rec in self:
|
||||
rec.write({
|
||||
'state': 'applied',
|
||||
'applied_at': fields.Datetime.now(),
|
||||
'applied_by_id': self.env.user.id,
|
||||
})
|
||||
rec.bath_id.message_post(
|
||||
body=f'Replenishment applied: {rec.dose_amount} {rec.dose_uom} '
|
||||
f'of {rec.product_name} (parameter: {rec.parameter_id.name})'
|
||||
)
|
||||
|
||||
def action_dismiss(self):
|
||||
self.write({'state': 'dismissed'})
|
||||
117
fusion_plating/fusion_plating/models/fp_rack.py
Normal file
117
fusion_plating/fusion_plating/models/fp_rack.py
Normal 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 FpRack(models.Model):
|
||||
"""Plating rack / barrel / fixture.
|
||||
|
||||
Racks carry parts through baths and accumulate nickel themselves over
|
||||
time. Once the rack's metal turnover (MTO) count exceeds the strip
|
||||
interval, the rack must be stripped before re-use to avoid bald spots
|
||||
on parts.
|
||||
"""
|
||||
_name = 'fusion.plating.rack'
|
||||
_description = 'Fusion Plating — Rack / Fixture'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_order = 'facility_id, rack_type, name'
|
||||
|
||||
name = fields.Char(string='Rack ID', required=True, tracking=True)
|
||||
rack_type = fields.Selection(
|
||||
[('rack', 'Rack'), ('barrel', 'Barrel'),
|
||||
('fixture', 'Fixture'), ('basket', 'Basket')],
|
||||
string='Type', required=True, default='rack',
|
||||
)
|
||||
facility_id = fields.Many2one(
|
||||
'fusion.plating.facility', string='Facility', required=True, tracking=True,
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
'res.company', related='facility_id.company_id', store=True, readonly=True,
|
||||
)
|
||||
capacity = fields.Integer(
|
||||
string='Capacity (parts)',
|
||||
help='Max parts per load. Used for batch planning.',
|
||||
)
|
||||
contact_points = fields.Integer(
|
||||
string='Contact Points',
|
||||
help='Number of clips/tips that touch parts. Wear points for re-stripping.',
|
||||
)
|
||||
|
||||
# --- Wear tracking ---
|
||||
mto_count = fields.Float(
|
||||
string='MTO (current)', default=0.0, tracking=True,
|
||||
help='Metal turnover accumulated since last strip.',
|
||||
)
|
||||
strip_interval_mto = fields.Float(
|
||||
string='Strip After (MTO)', default=3.0,
|
||||
help='When MTO crosses this value, rack needs stripping.',
|
||||
)
|
||||
last_stripped_date = fields.Datetime(string='Last Stripped', tracking=True)
|
||||
last_stripped_by_id = fields.Many2one(
|
||||
'res.users', string='Stripped By', tracking=True,
|
||||
)
|
||||
strips_count = fields.Integer(string='Total Strips', default=0, readonly=True)
|
||||
|
||||
state = fields.Selection(
|
||||
[('active', 'Active'),
|
||||
('needs_strip', 'Needs Strip'),
|
||||
('stripping', 'Stripping'),
|
||||
('retired', 'Retired')],
|
||||
string='Status', default='active', required=True, tracking=True,
|
||||
compute='_compute_state', store=True, readonly=False,
|
||||
)
|
||||
status_color = fields.Integer(compute='_compute_status_color')
|
||||
notes = fields.Html(string='Notes')
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
_sql_constraints = [
|
||||
('fp_rack_facility_name_uniq', 'unique(facility_id, name)',
|
||||
'Rack ID must be unique per facility.'),
|
||||
]
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Computes
|
||||
# ------------------------------------------------------------------
|
||||
@api.depends('mto_count', 'strip_interval_mto')
|
||||
def _compute_state(self):
|
||||
for rec in self:
|
||||
if rec.state in ('stripping', 'retired'):
|
||||
continue # Manually set — don't override
|
||||
if rec.strip_interval_mto and rec.mto_count >= rec.strip_interval_mto:
|
||||
rec.state = 'needs_strip'
|
||||
elif rec.state != 'active':
|
||||
rec.state = 'active'
|
||||
|
||||
@api.depends('state')
|
||||
def _compute_status_color(self):
|
||||
mapping = {'active': 4, 'needs_strip': 3, 'stripping': 2, 'retired': 10}
|
||||
for rec in self:
|
||||
rec.status_color = mapping.get(rec.state, 0)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Actions
|
||||
# ------------------------------------------------------------------
|
||||
def action_start_strip(self):
|
||||
self.write({'state': 'stripping'})
|
||||
|
||||
def action_mark_stripped(self):
|
||||
for rec in self:
|
||||
rec.write({
|
||||
'state': 'active',
|
||||
'mto_count': 0.0,
|
||||
'last_stripped_date': fields.Datetime.now(),
|
||||
'last_stripped_by_id': self.env.user.id,
|
||||
'strips_count': rec.strips_count + 1,
|
||||
})
|
||||
rec.message_post(body=_('Rack stripped and returned to service.'))
|
||||
|
||||
def action_retire(self):
|
||||
self.write({'state': 'retired', 'active': False})
|
||||
|
||||
def _increment_mto(self, delta=1.0):
|
||||
"""Add `delta` to the rack's MTO count. Called by the WO finish hook."""
|
||||
for rec in self:
|
||||
rec.mto_count = (rec.mto_count or 0.0) + delta
|
||||
Reference in New Issue
Block a user