feat(label): Switch to custom barcode with numbers only

This commit is contained in:
Andreas Mieke 2024-04-20 21:51:01 -04:00
parent a732fb3d4a
commit 43c5c8a5ba
Signed by: zenermerps
SSH key fingerprint: SHA256:Ne+hwc5QIgYlqCuLZ0LV3301Wo/p8UoGOrGC+T6S0t8

View file

@ -42,18 +42,24 @@ class PhomemoLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):
port = int(self.get_setting('PORT'))
object_to_print = kwargs['label_instance'].object_to_print
key = object_to_print.pk
kind = ''
if kwargs['label_instance'].SUBDIR == 'part':
match kwargs['label_instance'].SUBDIR:
case 'part':
tpart = object_to_print
kind = 'part'
elif kwargs['label_instance'].SUBDIR == 'stockitem':
barcode = '1' + str(object_to_print.pk)
case 'stockitem':
tpart = object_to_print.part
kind = 'stockitem'
else:
barcode = '2' + str(object_to_print.pk)
case 'location':
tpart = object_to_print
barcode = '3' + str(object_to_print.pk)
case 'build':
tpart = object_to_print
barcode = '4' + str(object_to_print.pk)
case _:
tpart = object_to_print
barcode = '0' + str(object_to_print.pk)
print(f"!! Unsupported item type: {object_to_print.SUBDIR}")
return
fields = {
'name': tpart.name,
@ -62,8 +68,7 @@ class PhomemoLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):
'params': tpart.parameters_map(),
'category': tpart.category.name,
'category_path': tpart.category.pathstring,
'kind': kind,
'ppk': key
'barcode': barcode
}
data = json.dumps(fields)