changes
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
'name': 'Fusion Plating — Certificates',
|
||||
'version': '19.0.4.0.0',
|
||||
'version': '19.0.5.0.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Certificate registry for CoC, thickness reports, and quality documents.',
|
||||
'description': """
|
||||
@@ -27,7 +27,6 @@ Includes Fischerscope thickness measurement data capture.
|
||||
'fusion_plating_portal',
|
||||
'fusion_plating_batch',
|
||||
'fusion_plating_configurator',
|
||||
'mrp',
|
||||
'sale_management',
|
||||
],
|
||||
'data': [
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Phase 6 (Sub 11) — drop legacy MRP columns from certificate tables.
|
||||
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if not version:
|
||||
return
|
||||
cr.execute("ALTER TABLE fp_certificate DROP COLUMN IF EXISTS production_id")
|
||||
cr.execute("ALTER TABLE fp_thickness_reading DROP COLUMN IF EXISTS production_id")
|
||||
_logger.info("Sub 11: dropped production_id from fp_certificate + fp_thickness_reading")
|
||||
@@ -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.'))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class FpThicknessReading(models.Model):
|
||||
@@ -20,9 +20,8 @@ class FpThicknessReading(models.Model):
|
||||
certificate_id = fields.Many2one(
|
||||
'fp.certificate', string='Certificate', ondelete='cascade',
|
||||
)
|
||||
production_id = fields.Many2one(
|
||||
'mrp.production', string='Manufacturing Order',
|
||||
)
|
||||
# Phase 6 (Sub 11) — production_id retired (MRP module gone).
|
||||
# Thickness readings link via certificate_id and quality_check_id.
|
||||
reading_number = fields.Integer(
|
||||
string='Reading #', default=1, help='Sequence number (n=1, n=2, n=3).',
|
||||
)
|
||||
@@ -65,3 +64,14 @@ class FpThicknessReading(models.Model):
|
||||
measuring_time_seconds = fields.Integer(
|
||||
string='Measuring Time (sec)', default=120,
|
||||
)
|
||||
|
||||
@api.depends('reading_number', 'nip_mils', 'certificate_id')
|
||||
def _compute_display_name(self):
|
||||
for rec in self:
|
||||
ctx = rec.certificate_id.display_name or ''
|
||||
label = 'Reading #%d' % (rec.reading_number or 0)
|
||||
if rec.nip_mils:
|
||||
label = '%s (%.4f mils)' % (label, rec.nip_mils)
|
||||
if ctx:
|
||||
label = '%s — %s' % (label, ctx)
|
||||
rec.display_name = label
|
||||
|
||||
@@ -72,7 +72,6 @@
|
||||
<field name="certificate_type"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="sale_order_id"/>
|
||||
<field name="production_id"/>
|
||||
<field name="portal_job_id"/>
|
||||
<field name="issue_date"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user