fix(receiving): drop dead staged state — Option B (draft→counted→closed)
Reported 2026-05-20: the receiving state machine had four states (draft → counted → staged → closed) where the middle pair was pure ceremony. Real-usage data on entech: state distribution: 14 draft, 4 closed (zero `staged` records) median dwell counted → staged: 11 seconds median dwell staged → closed: 4 minutes `staged` captured no fields, fired no gates, mapped to the same SO `x_fc_receiving_status='partial'` as `counted`. Pure click-through. Cleanup: - State Selection retains `staged` as `Staged (legacy)` so historical records remain readable; new transitions never write it. - statusbar_visible drops it from the chevron header. - action_mark_staged becomes a thin shim that advances counted → closed directly (any old button binding still works). - action_close now accepts `counted` as a valid source state (was previously only `staged` / legacy `accepted` / `resolved`). - View: "Stage for Racking" button removed. "Close" button renamed to "Close — Racking Confirmed" so the racking-crew confirmation meaning stays obvious. - _update_so_receiving_status mapping unchanged for legacy `staged` (still maps to partial) — only the comment block updated to describe the new canonical flow. Migration 19.0.3.20.0 advances any `staged` records to `closed` and syncs the linked SO's x_fc_receiving_status to `received` so downstream gates (job step start, mark_done qty check, cert creation) don't see a stale "partial" status. Module: fusion_plating_receiving 19.0.3.19.0 → 19.0.3.20.0. Tests: TestQtyReceivedPropagation updated — 5 tests dropped the action_mark_staged() call, walk draft → counted → closed directly. All 11 tests green (carrier 6 + propagation 5). Verified on entech: existing 14 draft + 4 closed records untouched. Direct draft → counted → closed transition works end-to-end on RCV-30041 (was the test target). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -57,9 +57,9 @@ class TestQtyReceivedPropagation(TransactionCase):
|
|||||||
"""The bug: WO-30043 had qty_received=0 after receiving closed."""
|
"""The bug: WO-30043 had qty_received=0 after receiving closed."""
|
||||||
so, job = self._make_so_with_job()
|
so, job = self._make_so_with_job()
|
||||||
recv = self._make_receiving(so, received_qty=5)
|
recv = self._make_receiving(so, received_qty=5)
|
||||||
# Walk the state machine to closed.
|
# Walk the state machine to closed (draft → counted → closed
|
||||||
|
# after the 2026-05-20 `staged` retirement).
|
||||||
recv.action_mark_counted()
|
recv.action_mark_counted()
|
||||||
recv.action_mark_staged()
|
|
||||||
recv.action_close()
|
recv.action_close()
|
||||||
# Reload — the hook fires inside _update_so_receiving_status.
|
# Reload — the hook fires inside _update_so_receiving_status.
|
||||||
job.invalidate_recordset(['qty_received'])
|
job.invalidate_recordset(['qty_received'])
|
||||||
@@ -98,7 +98,6 @@ class TestQtyReceivedPropagation(TransactionCase):
|
|||||||
})
|
})
|
||||||
# Should NOT raise.
|
# Should NOT raise.
|
||||||
recv.action_mark_counted()
|
recv.action_mark_counted()
|
||||||
recv.action_mark_staged()
|
|
||||||
recv.action_close()
|
recv.action_close()
|
||||||
|
|
||||||
def test_multi_part_so_matches_per_part(self):
|
def test_multi_part_so_matches_per_part(self):
|
||||||
@@ -137,7 +136,6 @@ class TestQtyReceivedPropagation(TransactionCase):
|
|||||||
'expected_qty': 7, 'received_qty': 7,
|
'expected_qty': 7, 'received_qty': 7,
|
||||||
})
|
})
|
||||||
recv.action_mark_counted()
|
recv.action_mark_counted()
|
||||||
recv.action_mark_staged()
|
|
||||||
recv.action_close()
|
recv.action_close()
|
||||||
job_a.invalidate_recordset(['qty_received'])
|
job_a.invalidate_recordset(['qty_received'])
|
||||||
job_b.invalidate_recordset(['qty_received'])
|
job_b.invalidate_recordset(['qty_received'])
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Fusion Plating — Receiving & Inspection',
|
'name': 'Fusion Plating — Receiving & Inspection',
|
||||||
'version': '19.0.3.19.0',
|
'version': '19.0.3.20.0',
|
||||||
'category': 'Manufacturing/Plating',
|
'category': 'Manufacturing/Plating',
|
||||||
'summary': 'Parts receiving, inspection, damage logging, and manufacturing gate.',
|
'summary': 'Parts receiving, inspection, damage logging, and manufacturing gate.',
|
||||||
'description': """
|
'description': """
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2026 Nexa Systems Inc.
|
||||||
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||||
|
#
|
||||||
|
# 2026-05-20 — `staged` state retirement.
|
||||||
|
#
|
||||||
|
# Drop `staged` from the active receiving state machine. The state had
|
||||||
|
# zero downstream effect (same SO mapping as counted), no captured
|
||||||
|
# data, and median dwell of 11 sec — pure ceremony between Counted
|
||||||
|
# and Closed. Any existing records currently sitting in `staged` get
|
||||||
|
# promoted to `closed` (they're already past the box-count step;
|
||||||
|
# closed is the next logical resting place).
|
||||||
|
#
|
||||||
|
# `staged` stays in the Selection as a (legacy) value so historical
|
||||||
|
# records that ever held it can still be read — we just don't write
|
||||||
|
# to it anymore. The view's statusbar_visible drops it.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def migrate(cr, version):
|
||||||
|
cr.execute("""
|
||||||
|
UPDATE fp_receiving
|
||||||
|
SET state = 'closed'
|
||||||
|
WHERE state = 'staged'
|
||||||
|
""")
|
||||||
|
n = cr.rowcount
|
||||||
|
if n:
|
||||||
|
_logger.info(
|
||||||
|
'`staged` retirement: advanced %d receiving record(s) to '
|
||||||
|
'closed (state was dead ceremony, median dwell 11 sec).',
|
||||||
|
n,
|
||||||
|
)
|
||||||
|
# Mirror the new state onto the linked sale orders so downstream
|
||||||
|
# gates (job step start, mark_done qty check, cert creation)
|
||||||
|
# see the right `received` status without waiting for the next
|
||||||
|
# state-transition action.
|
||||||
|
cr.execute("""
|
||||||
|
UPDATE sale_order so
|
||||||
|
SET x_fc_receiving_status = 'received'
|
||||||
|
FROM fp_receiving r
|
||||||
|
WHERE r.sale_order_id = so.id
|
||||||
|
AND r.state = 'closed'
|
||||||
|
AND so.x_fc_receiving_status != 'received'
|
||||||
|
""")
|
||||||
|
if cr.rowcount:
|
||||||
|
_logger.info(
|
||||||
|
'`staged` retirement: synced %d sale_order.x_fc_receiving'
|
||||||
|
'_status to "received".', cr.rowcount,
|
||||||
|
)
|
||||||
@@ -54,9 +54,14 @@ class FpReceiving(models.Model):
|
|||||||
[
|
[
|
||||||
('draft', 'Awaiting Parts'),
|
('draft', 'Awaiting Parts'),
|
||||||
('counted', 'Counted'),
|
('counted', 'Counted'),
|
||||||
('staged', 'Staged for Racking'),
|
|
||||||
('closed', 'Closed'),
|
('closed', 'Closed'),
|
||||||
# Legacy values — kept readable, never written by new code
|
# Legacy values — kept readable, never written by new code.
|
||||||
|
# 2026-05-20: `staged` collapsed away. The state had zero
|
||||||
|
# downstream effect (same SO mapping as counted, no field
|
||||||
|
# captured, action_mark_staged just flipped a flag) and
|
||||||
|
# median dwell was 11 sec — pure ceremony. Pre-migrate
|
||||||
|
# advances any existing 'staged' record to 'closed'.
|
||||||
|
('staged', 'Staged (legacy)'),
|
||||||
('inspecting', 'Inspecting (legacy)'),
|
('inspecting', 'Inspecting (legacy)'),
|
||||||
('accepted', 'Accepted (legacy)'),
|
('accepted', 'Accepted (legacy)'),
|
||||||
('discrepancy', 'Discrepancy (legacy)'),
|
('discrepancy', 'Discrepancy (legacy)'),
|
||||||
@@ -768,20 +773,33 @@ class FpReceiving(models.Model):
|
|||||||
) % {'user': self.env.user.name, 'n': rec.box_count_in})
|
) % {'user': self.env.user.name, 'n': rec.box_count_in})
|
||||||
|
|
||||||
def action_mark_staged(self):
|
def action_mark_staged(self):
|
||||||
"""Boxes are in the racking area, awaiting the racking crew."""
|
"""Deprecated 2026-05-20 — `staged` state was dead ceremony
|
||||||
|
(median dwell 11 sec, no captured data, no downstream effect).
|
||||||
|
Kept as a thin shim so any legacy button binding still works:
|
||||||
|
it advances counted records straight to closed.
|
||||||
|
"""
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.state not in ('counted',):
|
if rec.state != 'counted':
|
||||||
raise UserError(_('Only Counted records can be marked Staged.'))
|
raise UserError(_(
|
||||||
rec.state = 'staged'
|
'Only Counted records can be closed. Stage-for-racking '
|
||||||
rec._update_so_receiving_status()
|
'is no longer a separate step.'
|
||||||
rec.message_post(body=_('Boxes staged for racking.'))
|
))
|
||||||
|
rec.action_close()
|
||||||
|
|
||||||
def action_close(self):
|
def action_close(self):
|
||||||
"""Close the receiving — all boxes opened, inspection complete."""
|
"""Close the receiving — all boxes opened, inspection complete.
|
||||||
|
|
||||||
|
2026-05-20: now reachable directly from `counted` (the `staged`
|
||||||
|
intermediate was dropped). Legacy values 'staged' / 'accepted'
|
||||||
|
/ 'resolved' still accepted so pre-Sub-8 records can be closed
|
||||||
|
without manual SQL surgery.
|
||||||
|
"""
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.state not in ('staged', 'accepted', 'resolved'):
|
if rec.state not in ('counted', 'staged', 'accepted', 'resolved'):
|
||||||
raise UserError(_('Only Staged (or legacy Accepted / Resolved) '
|
raise UserError(_(
|
||||||
'records can be closed.'))
|
'Only Counted (or legacy Staged / Accepted / Resolved) '
|
||||||
|
'records can be closed.'
|
||||||
|
))
|
||||||
rec.state = 'closed'
|
rec.state = 'closed'
|
||||||
rec._update_so_receiving_status()
|
rec._update_so_receiving_status()
|
||||||
rec.message_post(body=_('Receiving closed.'))
|
rec.message_post(body=_('Receiving closed.'))
|
||||||
@@ -859,14 +877,16 @@ class FpReceiving(models.Model):
|
|||||||
def _update_so_receiving_status(self):
|
def _update_so_receiving_status(self):
|
||||||
"""Update the linked sale order's receiving status.
|
"""Update the linked sale order's receiving status.
|
||||||
|
|
||||||
Sub 8 maps the new box-count-only states (`counted`, `staged`,
|
Sub 8 + 2026-05-20 cleanup map the receiving states onto the
|
||||||
`closed`) onto the SO's `x_fc_receiving_status`:
|
SO's `x_fc_receiving_status`:
|
||||||
- draft -> not_received (no rows or just-created)
|
- draft -> not_received (no rows or just-created)
|
||||||
- counted / staged -> partial (boxes on dock, parts not yet
|
- counted -> partial (boxes on dock,
|
||||||
racked / inspected)
|
parts not yet racked)
|
||||||
- closed -> received (all boxes opened, racking done)
|
- closed -> received (all boxes opened,
|
||||||
Legacy states (inspecting / accepted / discrepancy / resolved) keep
|
racking confirmed)
|
||||||
their original mapping for back-compat with pre-Sub-8 records.
|
Legacy values (staged / inspecting / accepted / discrepancy /
|
||||||
|
resolved) keep their pre-Sub-8 / pre-cleanup mapping so
|
||||||
|
records that haven't been touched still resolve sanely.
|
||||||
"""
|
"""
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if not rec.sale_order_id:
|
if not rec.sale_order_id:
|
||||||
|
|||||||
@@ -40,21 +40,21 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Receiving">
|
<form string="Receiving">
|
||||||
<header>
|
<header>
|
||||||
<!-- Sub 8 — new primary flow: box count only -->
|
<!-- Sub 8 + 2026-05-20: draft → counted → closed.
|
||||||
|
`Stage for Racking` removed (was pure ceremony
|
||||||
|
between Counted and Closed, median dwell 11 sec,
|
||||||
|
no captured data). Receiver counts boxes, then
|
||||||
|
closes once the racking crew confirms. -->
|
||||||
<button name="action_mark_counted"
|
<button name="action_mark_counted"
|
||||||
string="Mark Counted"
|
string="Mark Counted"
|
||||||
type="object"
|
type="object"
|
||||||
class="btn-primary"
|
class="btn-primary"
|
||||||
invisible="state not in ('draft', 'inspecting')"/>
|
invisible="state not in ('draft', 'inspecting')"/>
|
||||||
<button name="action_mark_staged"
|
<button name="action_close"
|
||||||
string="Stage for Racking"
|
string="Close — Racking Confirmed"
|
||||||
type="object"
|
type="object"
|
||||||
class="btn-primary"
|
class="btn-primary"
|
||||||
invisible="state != 'counted'"/>
|
invisible="state not in ('counted', 'staged', 'accepted', 'resolved')"/>
|
||||||
<button name="action_close"
|
|
||||||
string="Close"
|
|
||||||
type="object"
|
|
||||||
invisible="state not in ('staged', 'accepted', 'resolved')"/>
|
|
||||||
<!-- Legacy actions (hidden by default; surfaces for old records) -->
|
<!-- Legacy actions (hidden by default; surfaces for old records) -->
|
||||||
<button name="action_accept"
|
<button name="action_accept"
|
||||||
string="Accept (legacy)"
|
string="Accept (legacy)"
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
icon="fa-file-pdf-o"
|
icon="fa-file-pdf-o"
|
||||||
invisible="not x_fc_outbound_shipment_id"/>
|
invisible="not x_fc_outbound_shipment_id"/>
|
||||||
<field name="state" widget="statusbar"
|
<field name="state" widget="statusbar"
|
||||||
statusbar_visible="draft,counted,staged,closed"/>
|
statusbar_visible="draft,counted,closed"/>
|
||||||
</header>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
<div class="oe_button_box" name="button_box">
|
<div class="oe_button_box" name="button_box">
|
||||||
|
|||||||
Reference in New Issue
Block a user