changes
This commit is contained in:
@@ -35,7 +35,8 @@ class FpCertificate(models.Model):
|
||||
domain="[('customer_rank', '>', 0)]",
|
||||
)
|
||||
sale_order_id = fields.Many2one('sale.order', string='Sale Order')
|
||||
production_id = fields.Many2one('mrp.production', string='Manufacturing Order')
|
||||
# Phase 6 (Sub 11) — production_id retired (MRP module gone).
|
||||
# Certificates link via sale_order_id + portal_job_id natively.
|
||||
portal_job_id = fields.Many2one('fusion.plating.portal.job', string='Portal Job')
|
||||
part_number = fields.Char(string='Part Number', help='Denormalized for fast search.')
|
||||
process_description = fields.Char(
|
||||
@@ -84,23 +85,32 @@ class FpCertificate(models.Model):
|
||||
string='Baths Used',
|
||||
)
|
||||
|
||||
@api.depends('production_id')
|
||||
@api.depends('sale_order_id')
|
||||
def _compute_batch_ids(self):
|
||||
# Phase 6 (Sub 11) — walks fp.job via SO instead of mrp.production.
|
||||
Batch = self.env.get('fusion.plating.batch')
|
||||
Bath = self.env['fusion.plating.bath']
|
||||
Job = self.env.get('fp.job')
|
||||
empty_batch = self.env['fusion.plating.batch']
|
||||
for rec in self:
|
||||
if Batch is not None and rec.production_id:
|
||||
batches = Batch.search([
|
||||
('production_id', '=', rec.production_id.id),
|
||||
])
|
||||
rec.batch_ids = batches
|
||||
rec.batch_count = len(batches)
|
||||
rec.bath_ids = batches.mapped('bath_id')
|
||||
else:
|
||||
if Batch is None or Job is None or not rec.sale_order_id:
|
||||
rec.batch_ids = empty_batch
|
||||
rec.batch_count = 0
|
||||
rec.bath_ids = Bath
|
||||
continue
|
||||
jobs = Job.search([('sale_order_id', '=', rec.sale_order_id.id)])
|
||||
if not jobs:
|
||||
rec.batch_ids = empty_batch
|
||||
rec.batch_count = 0
|
||||
rec.bath_ids = Bath
|
||||
continue
|
||||
if 'x_fc_job_id' in Batch._fields:
|
||||
batches = Batch.search([('x_fc_job_id', 'in', jobs.ids)])
|
||||
else:
|
||||
batches = empty_batch
|
||||
rec.batch_ids = batches
|
||||
rec.batch_count = len(batches)
|
||||
rec.bath_ids = batches.mapped('bath_id')
|
||||
state = fields.Selection(
|
||||
[('draft', 'Draft'), ('issued', 'Issued'), ('voided', 'Voided')],
|
||||
string='Status', default='draft', tracking=True, required=True,
|
||||
@@ -289,12 +299,12 @@ class FpCertificate(models.Model):
|
||||
'Cannot issue CoC "%(name)s" — customer "%(cust)s" '
|
||||
'requires actual thickness readings on every CoC '
|
||||
'(Nadcap / aerospace).\n\nLog Fischerscope readings '
|
||||
'against MO %(mo)s via the Tablet Station before '
|
||||
'issuing.'
|
||||
'against the job for SO %(so)s via the Tablet Station '
|
||||
'before issuing.'
|
||||
) % {
|
||||
'name': rec.name or rec.display_name,
|
||||
'cust': rec.partner_id.name,
|
||||
'mo': rec.production_id.name if rec.production_id else '?',
|
||||
'so': rec.sale_order_id.name if rec.sale_order_id else '?',
|
||||
})
|
||||
rec.state = 'issued'
|
||||
rec.message_post(body=_('Certificate issued.'))
|
||||
|
||||
Reference in New Issue
Block a user