feat(plating): Sub 8 — split receiving vs inspection + box parity
fp.receiving simplifies to box-count-only (new primary state machine: draft → counted → staged → closed). Legacy inspecting/accepted/discrepancy/resolved states stay in the Selection so existing records load without error but are surfaced behind a manager-only toggle. New box_count_in field + banner that tells the receiver "count boxes only — parts are inspected by the racking crew." New fp.racking.inspection + fp.racking.inspection.line models — one record per MO, auto-created by mrp.production.create() with one line per contributing SO line (qty_expected seeded, qty_found + condition filled in by the racking crew when they open the boxes). State: draft → inspecting → done | discrepancy_flagged (flagged when any line has a non-ok condition or qty variance). Reopen restricted to Plating Manager. WO soft gate: first plating WO button_start raises a UserError when the MO's racking inspection is still Draft or Inspecting. Plating Manager bypasses; later WOs are not gated. fp.delivery gains x_fc_box_count_out. action_mark_delivered calls _fp_check_box_parity which posts a non-blocking chatter warning when boxes out ≠ boxes in (resolved via job_ref → MO.origin → SO → receiving). Warning only — never blocks shipping. Menu entry: Plating → Operations → Racking Inspection. Module version bumps: fusion_plating_receiving → 19.0.3.0.0 fusion_plating_logistics → 19.0.3.0.0 fusion_plating_bridge_mrp → 19.0.12.0.0 (+depends receiving) Smoke on entech: 12/12 assertions pass (one gate test skipped — MO had no WOs to test) including box-count state machine, inspection auto-create, lifecycle, discrepancy flag, and box-parity chatter. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -39,16 +39,32 @@ class FpReceiving(models.Model):
|
||||
received_date = fields.Datetime(
|
||||
string='Received Date', default=fields.Datetime.now, tracking=True,
|
||||
)
|
||||
# Sub 8 — simplified state machine. Receiving = box count only. The
|
||||
# part-level inspection that used to happen here now lives on
|
||||
# fp.racking.inspection (racking crew does it when they open the
|
||||
# boxes). Legacy state values are kept in the Selection so existing
|
||||
# records from before Sub 8 don't raise on upgrade.
|
||||
state = fields.Selection(
|
||||
[
|
||||
('draft', 'Awaiting Parts'),
|
||||
('inspecting', 'Inspecting'),
|
||||
('accepted', 'Accepted'),
|
||||
('discrepancy', 'Discrepancy'),
|
||||
('resolved', 'Resolved'),
|
||||
('draft', 'Awaiting Parts'),
|
||||
('counted', 'Counted'),
|
||||
('staged', 'Staged for Racking'),
|
||||
('closed', 'Closed'),
|
||||
# Legacy values — kept readable, never written by new code
|
||||
('inspecting', 'Inspecting (legacy)'),
|
||||
('accepted', 'Accepted (legacy)'),
|
||||
('discrepancy', 'Discrepancy (legacy)'),
|
||||
('resolved', 'Resolved (legacy)'),
|
||||
],
|
||||
string='Status', default='draft', tracking=True, required=True,
|
||||
)
|
||||
box_count_in = fields.Integer(
|
||||
string='Boxes Received',
|
||||
tracking=True,
|
||||
help='Number of boxes the receiver counted when the truck '
|
||||
'dropped off. Receiving is box count only — parts are '
|
||||
'inspected by the racking crew when boxes are opened.',
|
||||
)
|
||||
expected_qty = fields.Integer(string='Expected Qty', help='Total quantity expected from the sale order.')
|
||||
received_qty = fields.Integer(string='Received Qty', help='Total quantity actually received.')
|
||||
qty_match = fields.Boolean(
|
||||
@@ -96,7 +112,46 @@ class FpReceiving(models.Model):
|
||||
return super().create(vals_list)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# State actions
|
||||
# Sub 8 — box-count-only actions (new primary flow)
|
||||
# -------------------------------------------------------------------------
|
||||
def action_mark_counted(self):
|
||||
"""Receiver has counted the boxes on the dock. Move to Counted."""
|
||||
for rec in self:
|
||||
if rec.state not in ('draft', 'inspecting'): # inspecting allows legacy records
|
||||
raise UserError(_('Only Awaiting-Parts or legacy-Inspecting '
|
||||
'records can be marked Counted.'))
|
||||
if not rec.box_count_in:
|
||||
raise UserError(_('Set the Boxes Received count before marking Counted.'))
|
||||
rec.state = 'counted'
|
||||
rec.received_by_id = self.env.user
|
||||
rec.received_date = fields.Datetime.now()
|
||||
rec.message_post(body=_(
|
||||
'%(user)s counted %(n)d box(es) at receiving.'
|
||||
) % {'user': self.env.user.name, 'n': rec.box_count_in})
|
||||
|
||||
def action_mark_staged(self):
|
||||
"""Boxes are in the racking area, awaiting the racking crew."""
|
||||
for rec in self:
|
||||
if rec.state not in ('counted',):
|
||||
raise UserError(_('Only Counted records can be marked Staged.'))
|
||||
rec.state = 'staged'
|
||||
rec._update_so_receiving_status()
|
||||
rec.message_post(body=_('Boxes staged for racking.'))
|
||||
|
||||
def action_close(self):
|
||||
"""Close the receiving — all boxes opened, inspection complete."""
|
||||
for rec in self:
|
||||
if rec.state not in ('staged', 'accepted', 'resolved'):
|
||||
raise UserError(_('Only Staged (or legacy Accepted / Resolved) '
|
||||
'records can be closed.'))
|
||||
rec.state = 'closed'
|
||||
rec._update_so_receiving_status()
|
||||
rec.message_post(body=_('Receiving closed.'))
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Legacy state actions — kept for backward compatibility.
|
||||
# Deprecated: Sub 8 moves part-level inspection to fp.racking.inspection.
|
||||
# Retained so existing UI bindings don't blow up.
|
||||
# -------------------------------------------------------------------------
|
||||
def action_start_inspection(self):
|
||||
"""Move from draft to inspecting."""
|
||||
|
||||
Reference in New Issue
Block a user