This commit is contained in:
gsinghpal
2026-04-28 19:39:37 -04:00
parent 2d42b33d68
commit 13e300d90e
103 changed files with 4959 additions and 331 deletions

View File

@@ -5,7 +5,7 @@
{
'name': 'Fusion Plating — Receiving & Inspection',
'version': '19.0.3.5.0',
'version': '19.0.3.7.0',
'category': 'Manufacturing/Plating',
'summary': 'Parts receiving, inspection, damage logging, and manufacturing gate.',
'description': """

View File

@@ -8,6 +8,8 @@
# boxes (which is DIFFERENT from receiving — receiving is box count
# only). One record per MO.
from dateutil.relativedelta import relativedelta
from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
@@ -151,6 +153,27 @@ class FpRackingInspection(models.Model):
'inspection_completed': fields.Datetime.now(),
})
if new_state == 'discrepancy_flagged':
# 2026-04-28 — Activity must land on a real user.
# Resolve the assignee in priority order:
# 1. The job's plating manager (if set on fp.job)
# 2. The inspector who just flagged it
# 3. The current user (env.uid fallback)
# `activity_schedule` defaults to env.uid only when the
# record has a `user_id` field; fp.racking.inspection
# has `inspector_id` but not `user_id`, so we'd land on
# False if we let it default. Explicit assignment is
# the only safe path.
assignee = False
if (rec.x_fc_job_id and 'manager_id' in rec.x_fc_job_id._fields
and rec.x_fc_job_id.manager_id):
assignee = rec.x_fc_job_id.manager_id.id
elif rec.inspector_id:
assignee = rec.inspector_id.id
else:
assignee = self.env.uid
# 3-day deadline so it surfaces in "Overdue" dashboards
# if not addressed before plating starts.
deadline = fields.Date.today() + relativedelta(days=3)
rec.activity_schedule(
'mail.mail_activity_data_todo',
summary=_('Racking discrepancy on %s') % (
@@ -160,6 +183,8 @@ class FpRackingInspection(models.Model):
'%(n)d line(s) flagged — review before starting '
'the first plating WO.'
) % {'n': rec.flagged_count},
user_id=assignee,
date_deadline=deadline,
)
rec.message_post(body=_(
'Inspection completed — %(ok)d ok / %(flag)d flagged.'
@@ -214,6 +239,50 @@ class FpRackingInspectionLine(models.Model):
)
notes = fields.Char(string='Notes')
# 2026-04-28 — photos on a line (compliance need: damage evidence,
# box-by-box condition record). Many2many to ir.attachment so an
# operator can shoot multiple angles per box from the floor without
# leaving the form. Cascade-deleted with the line.
photo_ids = fields.Many2many(
'ir.attachment',
relation='fp_racking_insp_line_photo_rel',
column1='line_id',
column2='attachment_id',
string='Photos',
domain="[('mimetype', 'ilike', 'image/')]",
help='Damage / condition photos for this box. Click + to upload '
'one or more from the camera roll. Cascades on delete.',
)
photo_count = fields.Integer(
string='# Photos',
compute='_compute_photo_count',
)
@api.depends('photo_ids')
def _compute_photo_count(self):
for rec in self:
rec.photo_count = len(rec.photo_ids)
@api.model_create_multi
def create(self, vals_list):
# Auto-populate part_catalog_id from the parent inspection's job
# when the operator added a line without picking a part. The
# job's SO carries the customer's part — pre-fill the line so
# the audit trail captures it without requiring extra clicks.
for vals in vals_list:
if not vals.get('part_catalog_id') and vals.get('inspection_id'):
ri = self.env['fp.racking.inspection'].browse(
vals['inspection_id'])
if ri.exists() and ri.x_fc_job_id:
so = ri.x_fc_job_id.sale_order_id
if so:
line = so.order_line.filtered(
lambda l: l.x_fc_part_catalog_id
)[:1]
if line:
vals['part_catalog_id'] = line.x_fc_part_catalog_id.id
return super().create(vals_list)
@api.depends('qty_expected', 'qty_found')
def _compute_qty_variance(self):
for rec in self:

View File

@@ -54,19 +54,56 @@
<notebook>
<page string="Inspection Lines" name="lines">
<field name="line_ids" readonly="state in ('done','discrepancy_flagged')">
<list editable="bottom"
decoration-warning="condition == 'minor' or qty_variance != 0"
<list decoration-warning="condition == 'minor' or qty_variance != 0"
decoration-danger="condition in ('major','reject')">
<field name="sequence" widget="handle"/>
<field name="part_catalog_id"/>
<field name="part_number" readonly="1"/>
<field name="part_revision" readonly="1"/>
<field name="qty_expected"/>
<field name="qty_found"/>
<field name="qty_variance" readonly="1"/>
<field name="part_catalog_id"
string="Part"/>
<field name="part_number"
string="Part #"
readonly="1" optional="show"/>
<field name="part_revision"
string="Rev"
readonly="1" optional="show"/>
<field name="qty_expected"
string="Expected"/>
<field name="qty_found"
string="Counted"/>
<field name="qty_variance"
string="Δ"
readonly="1"/>
<field name="condition"/>
<field name="notes"/>
<field name="photo_count"
string="📷"
optional="show"/>
<field name="notes" optional="show"/>
</list>
<form string="Inspection Line">
<sheet>
<group>
<group string="Part">
<field name="part_catalog_id"/>
<field name="part_number" readonly="1"/>
<field name="part_revision" readonly="1"/>
<field name="sequence"/>
</group>
<group string="Counts">
<field name="qty_expected"/>
<field name="qty_found"/>
<field name="qty_variance" readonly="1"/>
<field name="condition"/>
</group>
</group>
<separator string="Photos"/>
<field name="photo_ids"
widget="many2many_binary"
nolabel="1"
help="Drag &amp; drop or click to attach damage / condition photos for this box."/>
<separator string="Notes"/>
<field name="notes" nolabel="1"
placeholder="Box number, serial range, what was found, who flagged it, what photos cover..."/>
</sheet>
</form>
</field>
</page>
<page string="Notes" name="notes">