feat: printer duplicate copies setting (Feature 1)
- Add `duplicates` column (0-9) to printers table via migration - Print loop repeats job 1+duplicates times per printer zone - PrinterForm in Settings > Print now has ΑΝΤΙΓΡΑΦΑ (0-9) field - PrinterRow shows amber badge when duplicates > 0 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -406,6 +406,8 @@ def _run_migrations():
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
priority VARCHAR NOT NULL DEFAULT 'normal'
|
||||
)""",
|
||||
# Printer duplicate copies (0 = print once, 1 = print twice, etc.)
|
||||
"ALTER TABLE printers ADD COLUMN duplicates INTEGER NOT NULL DEFAULT 0",
|
||||
]
|
||||
for sql in migrations:
|
||||
try:
|
||||
|
||||
@@ -13,6 +13,7 @@ class Printer(Base):
|
||||
is_active = Column(Boolean, default=True, nullable=False)
|
||||
protocol = Column(String, default="escpos_tcp", nullable=False)
|
||||
line_width = Column(Integer, default=48, nullable=False)
|
||||
duplicates = Column(Integer, default=0, nullable=False)
|
||||
|
||||
products = relationship("Product", back_populates="printer_zone")
|
||||
print_logs = relationship("PrintLog", back_populates="printer")
|
||||
|
||||
@@ -12,6 +12,7 @@ class PrinterBase(BaseModel):
|
||||
is_active: bool = True
|
||||
protocol: str = "escpos_tcp"
|
||||
line_width: int = 48
|
||||
duplicates: int = 0
|
||||
|
||||
|
||||
class PrinterCreate(PrinterBase):
|
||||
@@ -25,6 +26,7 @@ class PrinterUpdate(BaseModel):
|
||||
is_active: Optional[bool] = None
|
||||
protocol: Optional[str] = None
|
||||
line_width: Optional[int] = None
|
||||
duplicates: Optional[int] = None
|
||||
|
||||
|
||||
class PrinterOut(PrinterBase):
|
||||
|
||||
@@ -1256,10 +1256,12 @@ def _do_route_and_print(order_id: int, item_ids: List[int], db: Session) -> List
|
||||
|
||||
success = False
|
||||
error_msg = None
|
||||
copies = 1 + max(0, printer.duplicates or 0)
|
||||
try:
|
||||
p = _get_printer(printer.ip_address, printer.port)
|
||||
_print_kitchen_ticket(p, order, zone_items, db, printer.line_width)
|
||||
p.close()
|
||||
for _ in range(copies):
|
||||
p = _get_printer(printer.ip_address, printer.port)
|
||||
_print_kitchen_ticket(p, order, zone_items, db, printer.line_width)
|
||||
p.close()
|
||||
success = True
|
||||
for item in zone_items:
|
||||
item.printed = True
|
||||
|
||||
Reference in New Issue
Block a user