feat(label): Switch to custom barcode with numbers only
This commit is contained in:
parent
a732fb3d4a
commit
43c5c8a5ba
1 changed files with 18 additions and 13 deletions
|
@ -42,18 +42,24 @@ class PhomemoLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):
|
||||||
port = int(self.get_setting('PORT'))
|
port = int(self.get_setting('PORT'))
|
||||||
|
|
||||||
object_to_print = kwargs['label_instance'].object_to_print
|
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:
|
||||||
tpart = object_to_print
|
case 'part':
|
||||||
kind = 'part'
|
tpart = object_to_print
|
||||||
elif kwargs['label_instance'].SUBDIR == 'stockitem':
|
barcode = '1' + str(object_to_print.pk)
|
||||||
tpart = object_to_print.part
|
case 'stockitem':
|
||||||
kind = 'stockitem'
|
tpart = object_to_print.part
|
||||||
else:
|
barcode = '2' + str(object_to_print.pk)
|
||||||
print(f"!! Unsupported item type: {object_to_print.SUBDIR}")
|
case 'location':
|
||||||
return
|
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}")
|
||||||
|
|
||||||
fields = {
|
fields = {
|
||||||
'name': tpart.name,
|
'name': tpart.name,
|
||||||
|
@ -62,8 +68,7 @@ class PhomemoLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):
|
||||||
'params': tpart.parameters_map(),
|
'params': tpart.parameters_map(),
|
||||||
'category': tpart.category.name,
|
'category': tpart.category.name,
|
||||||
'category_path': tpart.category.pathstring,
|
'category_path': tpart.category.pathstring,
|
||||||
'kind': kind,
|
'barcode': barcode
|
||||||
'ppk': key
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data = json.dumps(fields)
|
data = json.dumps(fields)
|
||||||
|
|
Loading…
Add table
Reference in a new issue