diff --git a/InvenTree/label/migrations/0006_auto_20210222_0952.py b/InvenTree/label/migrations/0006_auto_20210222_0952.py new file mode 100644 index 0000000000..62e9d1a7f5 --- /dev/null +++ b/InvenTree/label/migrations/0006_auto_20210222_0952.py @@ -0,0 +1,34 @@ +# Generated by Django 3.0.7 on 2021-02-21 22:52 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('label', '0005_auto_20210113_2302'), + ] + + operations = [ + migrations.AddField( + model_name='stockitemlabel', + name='length', + field=models.FloatField(default=20, help_text='Label length, specified in mm', validators=[django.core.validators.MinValueValidator(2)], verbose_name='Length [mm]'), + ), + migrations.AddField( + model_name='stockitemlabel', + name='width', + field=models.FloatField(default=10, help_text='Label width, specified in mm', validators=[django.core.validators.MinValueValidator(2)], verbose_name='Width [mm]'), + ), + migrations.AddField( + model_name='stocklocationlabel', + name='length', + field=models.FloatField(default=20, help_text='Label length, specified in mm', validators=[django.core.validators.MinValueValidator(2)], verbose_name='Length [mm]'), + ), + migrations.AddField( + model_name='stocklocationlabel', + name='width', + field=models.FloatField(default=10, help_text='Label width, specified in mm', validators=[django.core.validators.MinValueValidator(2)], verbose_name='Width [mm]'), + ), + ] diff --git a/InvenTree/label/models.py b/InvenTree/label/models.py index 9a98810d28..ae00bc0dc1 100644 --- a/InvenTree/label/models.py +++ b/InvenTree/label/models.py @@ -11,7 +11,7 @@ import io from blabel import LabelWriter from django.db import models -from django.core.validators import FileExtensionValidator +from django.core.validators import FileExtensionValidator, MinValueValidator from django.core.exceptions import ValidationError, FieldError from django.utils.translation import gettext_lazy as _ @@ -92,6 +92,20 @@ class LabelTemplate(models.Model): help_text=_('Label template is enabled'), ) + length = models.FloatField( + default=20, + verbose_name=_('Length [mm]'), + help_text=_('Label length, specified in mm'), + validators=[MinValueValidator(2)] + ) + + width = models.FloatField( + default=10, + verbose_name=('Width [mm]'), + help_text=_('Label width, specified in mm'), + validators=[MinValueValidator(2)] + ) + def get_record_data(self, items): """ Return a list of dict objects, one for each item.