refactor(backend): drop the legacy products.printer_zone_id and its print fallbacks
Routing has been by prep zone only since v1, which nulled this column on every start, so the four fallbacks in printer_service.py never ran. Revision 0012 drops the column (its unnamed FK goes with the batch rebuild). The unused legacy GET /api/kds/items keeps its single 'no zone' group. Product create/update/export/import no longer mention it. Scheduled in plan step 1.0 for the catalogue rework (1.13). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -447,7 +447,6 @@ def send_test_order_print(ip: str, port: int, db: Session, line_width: int = LIN
|
||||
name = _FAKE_NAMES[self._filter_id]
|
||||
unit_type = "piece"
|
||||
category_id = None
|
||||
printer_zone_id = None
|
||||
return _P()
|
||||
return _orig_query(self._model).filter(self._model.id == self._filter_id).first()
|
||||
|
||||
@@ -1409,17 +1408,6 @@ def _do_print_cancellation(order_id: int, item_ids: List[int], db: Session):
|
||||
printer_job[job_key][1].append(item)
|
||||
item_routed = True
|
||||
|
||||
# Fallback to legacy printer_zone_id
|
||||
if not item_routed and product.printer_zone_id:
|
||||
printer = db.query(Printer).filter(Printer.id == product.printer_zone_id, Printer.is_active == True).first()
|
||||
if printer:
|
||||
key = (printer.id, 0, item.id)
|
||||
if key not in seen:
|
||||
seen.add(key)
|
||||
job_key = (printer.id, 0)
|
||||
if job_key not in printer_job:
|
||||
printer_job[job_key] = (printer, [], None)
|
||||
printer_job[job_key][1].append(item)
|
||||
|
||||
div = load_divider_style(db)
|
||||
|
||||
@@ -1859,21 +1847,7 @@ def _do_route_and_print(order_id: int, item_ids: List[int], db: Session, ephemer
|
||||
if product.prep_zones and all((z.auto_print or 'none') == 'none' for z in product.prep_zones):
|
||||
printed_item_ids_no_print.add(item.id)
|
||||
continue
|
||||
# Fall back to legacy printer_zone_id (single printer, 1 copy, no zone formatting)
|
||||
if product.printer_zone_id:
|
||||
printer = db.query(Printer).filter(Printer.id == product.printer_zone_id, Printer.is_active == True).first()
|
||||
if printer:
|
||||
key = (printer.id, 1, 0, item.id)
|
||||
if key not in seen:
|
||||
seen.add(key)
|
||||
job_key = (printer.id, 1, 0)
|
||||
if job_key not in printer_job:
|
||||
printer_job[job_key] = ([], None)
|
||||
printer_job[job_key][0].append(item)
|
||||
else:
|
||||
unzoned.append(item)
|
||||
else:
|
||||
unzoned.append(item)
|
||||
unzoned.append(item)
|
||||
|
||||
if unzoned:
|
||||
logger.warning("order %s has %d item(s) with no prep zone/printer — skipped", order_id, len(unzoned))
|
||||
@@ -1915,16 +1889,6 @@ def _do_route_and_print(order_id: int, item_ids: List[int], db: Session, ephemer
|
||||
job_svc_entries[job_key] = []
|
||||
job_svc_entries[job_key].append(entry)
|
||||
entry_routed = True
|
||||
# Fallback: legacy printer_zone_id
|
||||
if not entry_routed and getattr(product, 'printer_zone_id', None):
|
||||
pr = db.query(Printer).filter(Printer.id == product.printer_zone_id, Printer.is_active == True).first()
|
||||
if pr:
|
||||
job_key = (pr.id, 1, 0)
|
||||
if job_key not in printer_job:
|
||||
printer_job[job_key] = ([], None)
|
||||
if job_key not in job_svc_entries:
|
||||
job_svc_entries[job_key] = []
|
||||
job_svc_entries[job_key].append(entry)
|
||||
|
||||
printed_item_ids: set[int] = set()
|
||||
|
||||
@@ -2071,14 +2035,6 @@ def print_service_items_sync(order: Order, service_entries: List[dict], db: Sess
|
||||
printer_job[job_key] = {'printer': pr, 'copies': copies, 'zone': z, 'entries': []}
|
||||
printer_job[job_key]['entries'].append({'product': product, 'quantity': quantity})
|
||||
|
||||
# Fallback: legacy printer_zone_id
|
||||
if not product.prep_zones and product.printer_zone_id:
|
||||
pr = db.query(Printer).filter(Printer.id == product.printer_zone_id, Printer.is_active == True).first()
|
||||
if pr:
|
||||
job_key = (pr.id, 1, 0)
|
||||
if job_key not in printer_job:
|
||||
printer_job[job_key] = {'printer': pr, 'copies': 1, 'zone': None, 'entries': []}
|
||||
printer_job[job_key]['entries'].append({'product': product, 'quantity': quantity})
|
||||
|
||||
for job_key, job in printer_job.items():
|
||||
pr = job['printer']
|
||||
|
||||
Reference in New Issue
Block a user