changes
This commit is contained in:
@@ -2,18 +2,55 @@
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
#
|
||||
# Phase 3 — parallel job link on fp.racking.inspection.
|
||||
# Coexists with the legacy production_id (mrp.production) link.
|
||||
# Phase 3 / Phase 9 — native-job link on fp.racking.inspection.
|
||||
# Coexists with the legacy production_id (mrp.production) link; either
|
||||
# (or both) may be set.
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class FpRackingInspection(models.Model):
|
||||
_inherit = 'fp.racking.inspection'
|
||||
|
||||
x_fc_job_id = fields.Many2one(
|
||||
'fp.job',
|
||||
string='Plating Job',
|
||||
index=True,
|
||||
help='Native fp.job link. Coexists with the legacy production_id.',
|
||||
)
|
||||
# x_fc_job_id is declared in the base receiving module so its views
|
||||
# can reference it. We add help/depends here.
|
||||
|
||||
@api.depends('x_fc_job_id.name', 'partner_id.name')
|
||||
def _compute_name(self):
|
||||
for rec in self:
|
||||
if rec.x_fc_job_id:
|
||||
rec.name = _('Inspection — %s') % rec.x_fc_job_id.name
|
||||
else:
|
||||
rec.name = _('Racking Inspection')
|
||||
|
||||
@api.depends('x_fc_job_id.sale_order_id')
|
||||
def _compute_sale_order(self):
|
||||
for rec in self:
|
||||
so = (rec.x_fc_job_id.sale_order_id
|
||||
if rec.x_fc_job_id and rec.x_fc_job_id.sale_order_id
|
||||
else False)
|
||||
rec.sale_order_id = so or False
|
||||
rec.partner_id = so.partner_id if so else False
|
||||
|
||||
@api.constrains('x_fc_job_id')
|
||||
def _check_link_present(self):
|
||||
for rec in self:
|
||||
if not rec.x_fc_job_id:
|
||||
raise ValidationError(_(
|
||||
'Racking inspection must reference a plating job.'
|
||||
))
|
||||
|
||||
@api.constrains('x_fc_job_id')
|
||||
def _check_job_unique(self):
|
||||
for rec in self:
|
||||
if not rec.x_fc_job_id:
|
||||
continue
|
||||
dup = self.search_count([
|
||||
('x_fc_job_id', '=', rec.x_fc_job_id.id),
|
||||
('id', '!=', rec.id),
|
||||
])
|
||||
if dup:
|
||||
raise ValidationError(_(
|
||||
'Only one racking inspection per plating job.'
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user