fix(label): Change code to more reflect the mixin
This commit is contained in:
parent
9460d923c9
commit
1cf5a58807
1 changed files with 8 additions and 12 deletions
|
@ -40,10 +40,10 @@ class PhomemoLabelPlugin(LabelPrintingMixin, BarcodeMixin, SettingsMixin, InvenT
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_fields(self, **kwargs):
|
def get_fields(self, label_instance):
|
||||||
object_to_print = kwargs['label_instance'].object_to_print
|
object_to_print = label_instance.object_to_print
|
||||||
|
|
||||||
match kwargs['label_instance'].SUBDIR:
|
match label_instance.SUBDIR:
|
||||||
case 'part':
|
case 'part':
|
||||||
tpart = object_to_print
|
tpart = object_to_print
|
||||||
barcode = '1' + str(object_to_print.pk)
|
barcode = '1' + str(object_to_print.pk)
|
||||||
|
@ -59,7 +59,7 @@ class PhomemoLabelPlugin(LabelPrintingMixin, BarcodeMixin, SettingsMixin, InvenT
|
||||||
case _:
|
case _:
|
||||||
tpart = object_to_print
|
tpart = object_to_print
|
||||||
barcode = '0' + str(object_to_print.pk)
|
barcode = '0' + str(object_to_print.pk)
|
||||||
print(f"!! Unsupported item type: {kwargs['label_instance'].SUBDIR}")
|
print(f"!! Unsupported item type: {label_instance.SUBDIR}")
|
||||||
|
|
||||||
fields = {
|
fields = {
|
||||||
'name': tpart.name,
|
'name': tpart.name,
|
||||||
|
@ -69,9 +69,9 @@ class PhomemoLabelPlugin(LabelPrintingMixin, BarcodeMixin, SettingsMixin, InvenT
|
||||||
'category': tpart.category.name if hasattr(tpart, 'category') else None,
|
'category': tpart.category.name if hasattr(tpart, 'category') else None,
|
||||||
'category_path': tpart.category.pathstring if hasattr(tpart, 'category') else None,
|
'category_path': tpart.category.pathstring if hasattr(tpart, 'category') else None,
|
||||||
'barcode': barcode,
|
'barcode': barcode,
|
||||||
'type': kwargs['label_instance'].SUBDIR,
|
'type': label_instance.SUBDIR,
|
||||||
'width': kwargs['width'],
|
'width': label_instance.width,
|
||||||
'height': kwargs['height']
|
'height': label_instance.height
|
||||||
}
|
}
|
||||||
|
|
||||||
return fields
|
return fields
|
||||||
|
@ -82,7 +82,7 @@ class PhomemoLabelPlugin(LabelPrintingMixin, BarcodeMixin, SettingsMixin, InvenT
|
||||||
# Get label content for every label
|
# Get label content for every label
|
||||||
for item in items:
|
for item in items:
|
||||||
label.object_to_print = item
|
label.object_to_print = item
|
||||||
outputs.append(self.print_label(label, request, **kwargs))
|
outputs.append(self.get_fields(label))
|
||||||
|
|
||||||
# Read settings
|
# Read settings
|
||||||
ip_address = self.get_setting('IP_ADDRESS')
|
ip_address = self.get_setting('IP_ADDRESS')
|
||||||
|
@ -106,10 +106,6 @@ class PhomemoLabelPlugin(LabelPrintingMixin, BarcodeMixin, SettingsMixin, InvenT
|
||||||
'message': f'{len(items)} labels printed',
|
'message': f'{len(items)} labels printed',
|
||||||
})
|
})
|
||||||
|
|
||||||
def print_label(self, label: LabelTemplate, request, **kwargs):
|
|
||||||
self.render_to_html(label, request, **kwargs)
|
|
||||||
return self.get_fields(**kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_supported_barcode_models():
|
def get_supported_barcode_models():
|
||||||
|
|
Loading…
Add table
Reference in a new issue