feat(plating): close 6 compliance gaps from required-fields audit
Following the workforce-E2E + required-fields audit, ship the first 6 high-priority gates so critical workflow + compliance fields can no longer be left empty by accident. **1. Invoice payment terms (account.move)** - create() now auto-inherits `invoice_payment_term_id` from partner.property_payment_term_id when missing - action_post() raises UserError if still missing — accountant must pick one before posting (prevents silent "immediate" due-date) **2. MO facility (mrp.production)** - action_confirm() auto-derives `x_fc_facility_id` if unset, in order: SO override → res.company.x_fc_default_facility_id → first active facility — then HARD GATES: raises UserError if still empty. Without facility every downstream record (WO, batch, bath log, cert) is missing the "where" half of the audit trail. **3. WO facility (mrp.workorder)** - Switched `x_fc_facility_id` from related (workcenter only) to a proper compute that falls back to production_id.x_fc_facility_id. Stub workcenters auto-created from process node names usually have no facility — the MO always does (from #2 above). **4. Thickness reading calibration_std (fp.thickness.reading)** - `calibration_std_ref` is now `required=True` with sensible default ("NiP/Al STD SET SN 100174568"). Nadcap mandates which calibration standard the gauge was checked against — without it the cert data has no chain back to a metrology record. **5. Delivery POD gate (fusion.plating.delivery)** - action_mark_delivered() raises UserError if no `pod_id`. Driver must capture POD on the iPad (recipient signature + photos + notes) BEFORE marking delivered. Without POD there's no signed receipt to back the invoice or defend a delivery dispute. **6. Certificate spec_reference gate (fp.certificate)** - action_issue() raises UserError if no `spec_reference`. The cert ATTESTS to a spec — leaving it blank produces a piece of paper that AS9100 / Nadcap auditors will (rightfully) reject. **Simulator updated**: scripts/fp_e2e_workforce.py - Sets net-30 on the test customer + ensures a default facility - New PHASE 4c: 5 negative tests (one per new gate), each wrapped in a SAVEPOINT so SQL constraint violations don't abort the txn - Driver now creates POD on iPad BEFORE marking delivered **Final E2E**: 48 PASS / 2 WARN / 0 FAIL out of 50 checks. The 2 remaining WARNs (bake-window auto-create, first-piece gate) are expected behaviour — both are coating-driven and the test coating intentionally doesn't trigger them. All 7 negative tests now pass: ✓ Test 1: WO start without operator → blocked ✓ Test 2: WO start on wet WO without bath/tank → blocked ✓ Test 3: MO confirm without facility → blocked ✓ Test 4: Cert issue without spec_reference → blocked ✓ Test 5: Delivery delivered without POD → blocked ✓ Test 6: Invoice post without payment terms → blocked ✓ Test 7: Thickness reading without cal std → blocked (DB NOT NULL) Audit script (scripts/fp_required_fields_audit.py) committed too — it's the diagnostic that surfaced these gaps and can be re-run to catch new ones. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
"name": "Fusion Plating — MRP Bridge",
|
||||
'version': '19.0.6.4.0',
|
||||
'version': '19.0.6.5.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Bridge Fusion Plating facilities, baths and tanks to Odoo MRP work orders.',
|
||||
'description': """
|
||||
|
||||
@@ -469,6 +469,40 @@ class MrpProduction(models.Model):
|
||||
# Auto-assign recipe BEFORE super() so work-order generation sees it
|
||||
self._auto_assign_recipe_from_so()
|
||||
|
||||
# Auto-derive facility (where the job runs) so x_fc_facility_id is
|
||||
# never empty downstream — it's compliance-critical (AS9100 §7.1.4
|
||||
# "infrastructure"). Order: explicit value > SO override >
|
||||
# company default > first active facility.
|
||||
for mo in self:
|
||||
if mo.x_fc_facility_id:
|
||||
continue
|
||||
facility = False
|
||||
if mo.origin:
|
||||
so = self.env['sale.order'].search(
|
||||
[('name', '=', mo.origin)], limit=1,
|
||||
)
|
||||
if so and 'x_fc_facility_id' in so._fields:
|
||||
facility = so.x_fc_facility_id
|
||||
if not facility:
|
||||
facility = mo.company_id.x_fc_default_facility_id
|
||||
if not facility:
|
||||
facility = self.env['fusion.plating.facility'].search(
|
||||
[('active', '=', True)], limit=1,
|
||||
)
|
||||
if facility:
|
||||
mo.x_fc_facility_id = facility.id
|
||||
|
||||
# Hard gate: MO can't be confirmed without a facility — without
|
||||
# this, every downstream record (WO, batch, bath log, cert) is
|
||||
# missing the "where" half of "what was made where by whom".
|
||||
for mo in self:
|
||||
if not mo.x_fc_facility_id:
|
||||
raise UserError(_(
|
||||
'Cannot confirm MO "%s" — no plating facility set.\n\n'
|
||||
'Set the facility on the MO, or configure a default '
|
||||
'in Settings → Companies → Fusion Plating Defaults.'
|
||||
) % (mo.name or mo.display_name))
|
||||
|
||||
res = super().action_confirm()
|
||||
PortalJob = self.env['fusion.plating.portal.job']
|
||||
for mo in self:
|
||||
|
||||
@@ -51,10 +51,24 @@ class MrpWorkorder(models.Model):
|
||||
string='Thickness Unit', default='mils',
|
||||
)
|
||||
x_fc_dwell_time_minutes = fields.Float(string='Dwell Time (min)')
|
||||
# Falls back to the MO's facility when the workcenter has none —
|
||||
# most stub workcenters auto-created from process node names don't
|
||||
# have facility_id, but the MO always does (enforced at confirm).
|
||||
x_fc_facility_id = fields.Many2one(
|
||||
'fusion.plating.facility', string='Facility',
|
||||
related='workcenter_id.x_fc_facility_id', store=True, readonly=True,
|
||||
compute='_compute_facility_id', store=True, readonly=False,
|
||||
help='Plating facility where this WO runs. Falls back to the '
|
||||
'MO\'s facility when the workcenter has none.',
|
||||
)
|
||||
|
||||
@api.depends('workcenter_id.x_fc_facility_id', 'production_id.x_fc_facility_id')
|
||||
def _compute_facility_id(self):
|
||||
for wo in self:
|
||||
wo.x_fc_facility_id = (
|
||||
wo.workcenter_id.x_fc_facility_id
|
||||
or wo.production_id.x_fc_facility_id
|
||||
or wo.x_fc_facility_id
|
||||
)
|
||||
x_fc_workcenter_cost_hour = fields.Float(
|
||||
string='Station Rate ($/hr)',
|
||||
related='workcenter_id.costs_hour', readonly=True,
|
||||
|
||||
Reference in New Issue
Block a user