92 lines
3.8 KiB
Python
92 lines
3.8 KiB
Python
# Step 4 — Mike receives parts. Walk the receiving form, fill every
|
|
# visible field, walk the state machine, verify SO status updates at
|
|
# every transition.
|
|
|
|
so = env['sale.order'].browse(423)
|
|
recv = env['fp.receiving'].search([('sale_order_id', '=', so.id)], limit=1)
|
|
print(f'[Mike] Looking at receiving {recv.name}: state={recv.state}, expected_qty={recv.expected_qty}')
|
|
|
|
# Mike sees the form. What's required vs optional?
|
|
print()
|
|
print('Visible fields on the receiving form (per fp_receiving_views.xml):')
|
|
print(f' sale_order_id: {recv.sale_order_id.name} (readonly via related)')
|
|
print(f' partner_id: {recv.partner_id.name} (related)')
|
|
print(f' po_number: {recv.po_number}')
|
|
print(f' box_count_in: {recv.box_count_in} <-- Mike must set this')
|
|
print(f' expected_qty: {recv.expected_qty}')
|
|
print(f' received_qty: {recv.received_qty} <-- defaults to expected_qty per Sub 8')
|
|
print(f' qty_match: {recv.qty_match}')
|
|
print(f' carrier_name: {recv.carrier_name} <-- Mike fills this')
|
|
print(f' carrier_tracking: {recv.carrier_tracking} <-- Mike fills this')
|
|
|
|
# Mike fills the carrier + tracking + counts the boxes.
|
|
print()
|
|
print('[Mike] Filling carrier + tracking + box count...')
|
|
recv.write({
|
|
'carrier_name': 'Purolator Ground',
|
|
'carrier_tracking': 'PUR-1Z9999E2E',
|
|
'box_count_in': 3,
|
|
'received_qty': 25, # all 25 arrived
|
|
'notes': '<p>Truck arrived 10am. Boxes look clean.</p>',
|
|
})
|
|
print(f' recv.qty_match = {recv.qty_match} (expected vs received)')
|
|
print(f' SO status BEFORE marking counted: {so.x_fc_receiving_status}')
|
|
|
|
# Click "Mark Counted"
|
|
print()
|
|
print('[Mike] Clicks "Mark Counted"')
|
|
try:
|
|
recv.action_mark_counted()
|
|
print(f' recv.state = {recv.state}')
|
|
print(f' recv.received_by_id = {recv.received_by_id.name}')
|
|
print(f' SO status AFTER mark counted: {so.x_fc_receiving_status}')
|
|
print(f' Expected: partial (boxes on dock, racking pending)')
|
|
assert so.x_fc_receiving_status == 'partial', 'SO status should be partial!'
|
|
print(' ✓ SO status correctly flipped to partial')
|
|
except Exception as e:
|
|
print(f' ❌ {e}')
|
|
|
|
# Click "Mark Staged"
|
|
print()
|
|
print('[Mike] Clicks "Mark Staged"')
|
|
try:
|
|
recv.action_mark_staged()
|
|
print(f' recv.state = {recv.state}')
|
|
print(f' SO status: {so.x_fc_receiving_status} (should still be partial)')
|
|
assert so.x_fc_receiving_status == 'partial'
|
|
print(' ✓ Still partial — racking not done yet')
|
|
except Exception as e:
|
|
print(f' ❌ {e}')
|
|
|
|
# Mike clicks the new "Racking Inspections" smart button (Round 2 fix)
|
|
print()
|
|
print('[Mike] Clicks the "Racking Inspections" smart button')
|
|
try:
|
|
act = recv.action_view_racking_inspections()
|
|
Inspection = env['fp.racking.inspection']
|
|
racks = Inspection.search(act.get('domain') or [])
|
|
print(f' Smart-button opens model={act.get("res_model")}, finds {len(racks)} inspection(s)')
|
|
for ri in racks:
|
|
print(f' {ri.name}: state={ri.state if "state" in ri._fields else "?"}, x_fc_job_id={ri.x_fc_job_id.name if ri.x_fc_job_id else None}')
|
|
except Exception as e:
|
|
print(f' ❌ {e}')
|
|
|
|
# At this point Mike's done — racking crew takes over.
|
|
# But the receiving stays at "staged" until racking crew finishes
|
|
# inspection and someone clicks "Close" on the receiving.
|
|
# Let's pretend racking is done and close the receiving.
|
|
print()
|
|
print('[Mike] (or shop manager) Clicks "Close Receiving" once racking is done')
|
|
try:
|
|
recv.action_close()
|
|
print(f' recv.state = {recv.state}')
|
|
print(f' SO status AFTER close: {so.x_fc_receiving_status}')
|
|
assert so.x_fc_receiving_status == 'received'
|
|
print(' ✓ SO status correctly flipped to received')
|
|
except Exception as e:
|
|
print(f' ❌ {e}')
|
|
|
|
print()
|
|
print(f'== Step 4 complete. SO {so.name} status={so.x_fc_receiving_status}, recv {recv.name} state={recv.state} ==')
|
|
env.cr.commit()
|