feat(jobs): Phase 3 light refactors — parallel job/step links on dependent models
Adds x_fc_job_id / x_fc_step_id Many2ones via _inherit on: - fusion.plating.batch (workorder_id stays for legacy MRP-bound batches) - fusion.plating.quality.hold - fp.certificate - fp.thickness.reading - fusion.plating.delivery (parallel to existing job_ref Char) - fp.racking.inspection (parallel to existing production_id) fp.job.action_confirm now also calls a best-effort racking-inspection auto-create. The current fp.racking.inspection still has a required production_id, so the helper skips cleanly when this job has no MO link (pure-native mode). Phase 9 cutover flips the required FK to fp.job. Strategy: parallel coexistence — bridge_mrp's existing fields stay populated; this adds NEW fields populated by the native flow. Phase 9 cutover stops populating the old fields. Adds fusion_plating_batch + fusion_plating_receiving to jobs module depends. Note: spec referenced fp.batch / fp.quality.hold; the actual models in this codebase are fusion.plating.batch / fusion.plating.quality.hold — used the real model names. Manifest 19.0.1.5.0 → 19.0.1.6.0. 29 jobs tests pass. Part of: native job model migration (spec 2026-04-25) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -259,8 +259,49 @@ class FpJob(models.Model):
|
||||
for job in self:
|
||||
job._fp_create_portal_job()
|
||||
job._fp_create_qc_check_if_needed()
|
||||
job._fp_create_racking_inspection()
|
||||
return result
|
||||
|
||||
def _fp_create_racking_inspection(self):
|
||||
"""Auto-create a draft racking inspection on job confirm.
|
||||
|
||||
Mirrors bridge_mrp's behaviour for MO confirm. Best-effort: the
|
||||
legacy fp.racking.inspection model still requires a production_id
|
||||
(mrp.production), so we can only create one when this job is
|
||||
bound to an MO via bridge_mrp. Otherwise we skip cleanly — Phase
|
||||
9 will flip the required-FK to fp.job.
|
||||
"""
|
||||
self.ensure_one()
|
||||
if 'fp.racking.inspection' not in self.env:
|
||||
return
|
||||
Inspection = self.env['fp.racking.inspection'].sudo()
|
||||
# The model still requires production_id today. If the job has
|
||||
# no MO link (which it won't in pure-native mode), skip rather
|
||||
# than crash. The link exists when fusion_plating_bridge_mrp is
|
||||
# installed and a production was created in parallel.
|
||||
production = False
|
||||
if 'production_id' in self._fields and self.production_id:
|
||||
production = self.production_id
|
||||
elif 'mrp_production_id' in self._fields and getattr(
|
||||
self, 'mrp_production_id', False):
|
||||
production = self.mrp_production_id
|
||||
if not production:
|
||||
_logger.debug(
|
||||
"Job %s: no MO link — skipping racking-inspection auto-create "
|
||||
"(required production_id not yet on fp.job).", self.name,
|
||||
)
|
||||
return
|
||||
try:
|
||||
vals = {'production_id': production.id}
|
||||
if 'x_fc_job_id' in Inspection._fields:
|
||||
vals['x_fc_job_id'] = self.id
|
||||
Inspection.create(vals)
|
||||
except Exception as e:
|
||||
_logger.warning(
|
||||
"Job %s: failed to auto-create racking inspection: %s",
|
||||
self.name, e,
|
||||
)
|
||||
|
||||
def _fp_create_portal_job(self):
|
||||
"""Create the fusion.plating.portal.job mirror record."""
|
||||
self.ensure_one()
|
||||
|
||||
Reference in New Issue
Block a user