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:
gsinghpal
2026-04-16 23:41:12 -04:00
parent 7c7ef06057
commit d3dd6376a6
51 changed files with 5231 additions and 197 deletions

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