printedparts: QR label with gage tag + revision; record taken rev

Label switches from CODE128 to a QR encoding 'TAG|rev' (gage lab tag + latest
print-file revision), so a physical part carries which revision it was printed
from - short payload stays low-version + reliable at 0.5in (margin quiet zone,
EC M, no logo). Item exposes latestrevision; kiosk strips the |rev to resolve
and records the scanned revision on the take (migration 0004 adds
printeditemtransactions.revision) for traceability of which rev was consumed.
Manual entry records a null revision.
This commit is contained in:
cproudlock
2026-07-22 07:52:17 -04:00
parent e85553e5e7
commit baf6862151
6 changed files with 151 additions and 34 deletions

View File

@@ -46,11 +46,20 @@ class PrintedItem(BaseModel):
def islowstock(self):
return self.quantityonhand <= self.lowstockthreshold
@property
def latestrevision(self):
"""Highest print-file revision, or None when the item has no files.
Stamped on the label QR so the physical part carries its source rev."""
from sqlalchemy import func
return db.session.query(func.max(PrintedItemFile.revision)).filter(
PrintedItemFile.printeditemid == self.printeditemid).scalar()
def to_dict(self):
return {
'printeditemid': self.printeditemid,
'itemcode': self.itemcode,
'gagelabtag': self.gagelabtag,
'latestrevision': self.latestrevision,
'itemname': self.itemname,
'itemdescription': self.itemdescription,
'imageurl': self.imageurl,
@@ -82,6 +91,10 @@ class PrintedItemTransaction(BaseModel):
employeesso = db.Column(db.String(20), nullable=False, index=True)
employeename = db.Column(db.String(120))
reason = db.Column(db.String(255))
# Print-file revision the physical part carried, captured from the label QR
# at take time (null for manual entry / pre-QR labels). Traceability of
# which revision was actually consumed.
revision = db.Column(db.Integer)
transactiondate = db.Column(db.DateTime, nullable=False, default=_utcnow,
index=True)
@@ -94,6 +107,7 @@ class PrintedItemTransaction(BaseModel):
'employeesso': self.employeesso,
'employeename': self.employeename,
'reason': self.reason,
'revision': self.revision,
'transactiondate': self.transactiondate.isoformat() + 'Z' if self.transactiondate else None,
}