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'))
|
||||
|
||||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue