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):
|
||||
object_to_print = kwargs['label_instance'].object_to_print
|
||||
def get_fields(self, label_instance):
|
||||
object_to_print = label_instance.object_to_print
|
||||
|
||||
match kwargs['label_instance'].SUBDIR:
|
||||
match label_instance.SUBDIR:
|
||||
case 'part':
|
||||
tpart = object_to_print
|
||||
barcode = '1' + str(object_to_print.pk)
|
||||
|
@ -59,7 +59,7 @@ class PhomemoLabelPlugin(LabelPrintingMixin, BarcodeMixin, SettingsMixin, InvenT
|
|||
case _:
|
||||
tpart = object_to_print
|
||||
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 = {
|
||||
'name': tpart.name,
|
||||
|
@ -69,9 +69,9 @@ class PhomemoLabelPlugin(LabelPrintingMixin, BarcodeMixin, SettingsMixin, InvenT
|
|||
'category': tpart.category.name if hasattr(tpart, 'category') else None,
|
||||
'category_path': tpart.category.pathstring if hasattr(tpart, 'category') else None,
|
||||
'barcode': barcode,
|
||||
'type': kwargs['label_instance'].SUBDIR,
|
||||
'width': kwargs['width'],
|
||||
'height': kwargs['height']
|
||||
'type': label_instance.SUBDIR,
|
||||
'width': label_instance.width,
|
||||
'height': label_instance.height
|
||||
}
|
||||
|
||||
return fields
|
||||
|
@ -82,7 +82,7 @@ class PhomemoLabelPlugin(LabelPrintingMixin, BarcodeMixin, SettingsMixin, InvenT
|
|||
# Get label content for every label
|
||||
for item in items:
|
||||
label.object_to_print = item
|
||||
outputs.append(self.print_label(label, request, **kwargs))
|
||||
outputs.append(self.get_fields(label))
|
||||
|
||||
# Read settings
|
||||
ip_address = self.get_setting('IP_ADDRESS')
|
||||
|
@ -106,10 +106,6 @@ class PhomemoLabelPlugin(LabelPrintingMixin, BarcodeMixin, SettingsMixin, InvenT
|
|||
'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
|
||||
def get_supported_barcode_models():
|
||||
|
|
Loading…
Add table
Reference in a new issue