Alpha6 barcode non scaffalate e bypass login

This commit is contained in:
2026-06-18 16:13:47 +02:00
parent cc9680c49a
commit 466778ae5f
19 changed files with 1614 additions and 48 deletions

View File

@@ -1,4 +1,11 @@
"""Read-only picking-list history window."""
"""Picking-list history window and controlled residual-shipment workflow.
The window is mostly read-only: it summarizes historical picking lists and shows
their UDC detail rows. The only write operation is the explicit, user-confirmed
"Versa residui in 7G.1.1" action for lists classified as closed with residuals.
That action delegates each UDC movement to ``move_pallet_async`` so the same
MagazziniPallet trace used by the rest of the WMS is preserved.
"""
from __future__ import annotations
@@ -21,6 +28,10 @@ from window_placement import place_window_fullsize_below_parent_later
__version__ = module_version(__name__)
# Master query:
# - reads the Python-only historical view, not the legacy C# views;
# - groups repeated lot rows by distinct UDC/PalletKey;
# - derives the operational status shown in the upper grid.
SQL_STORICO_PL = """
WITH base AS (
SELECT
@@ -85,6 +96,10 @@ WHERE (:documento IS NULL OR CAST(m.Documento AS varchar(32)) LIKE CONCAT('%', :
ORDER BY m.Documento DESC;
"""
# Detail query:
# - returns the ERP picking-list rows enriched with the current WMS cell;
# - may contain multiple rows for the same UDC when the pallet contains more lots;
# - is intentionally ordered by warehouse extraction order, then pallet.
SQL_STORICO_PL_DETAILS = """
SELECT
Documento,
@@ -455,12 +470,16 @@ class StoricoPickingListWindow(ctk.CTkToplevel):
seen: set[str] = set()
for row in rows:
pallet = str(row.get("Pallet") or "").strip()
# One UDC can appear on multiple detail rows when it contains
# multiple lots; movement must be executed once per physical UDC.
if not pallet or pallet in seen:
continue
try:
cella = int(row.get("Cella") or 0)
except Exception:
cella = 0
# IDCella 9999 is the conventional 7G.1.1 shipment cell. Rows
# already there are complete and must not receive another movement.
if cella == 9999:
continue
seen.add(pallet)
@@ -496,11 +515,17 @@ class StoricoPickingListWindow(ctk.CTkToplevel):
utente = self._operator_login()
async def _job():
# Re-read the detail inside the async job to avoid moving stale UI
# rows if another operator or barcode client changed the list after
# the user selected it.
detail_res = await self.db_client.query_json(SQL_STORICO_PL_DETAILS, {"documento": documento})
detail_rows = _rows_to_dicts(detail_res)
pallets = self._residual_pallets_from_rows(detail_rows)
results: list[dict[str, Any]] = []
for pallet in pallets:
# Reuse the central movement primitive: it closes the current
# source V row with a P movement and inserts a new V on 9999,
# preserving the historical trail required by Storico UDC.
result = await move_pallet_async(
self.db_client,
barcode_pallet=pallet,