diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py index 1cbbec0b42..4f55ccb14d 100644 --- a/InvenTree/part/forms.py +++ b/InvenTree/part/forms.py @@ -181,6 +181,7 @@ class EditPartForm(HelperForm): 'keywords': 'fa-key', 'link': 'fa-link', 'IPN': 'fa-hashtag', + 'default_expiry': 'fa-stopwatch', } bom_copy = forms.BooleanField(required=False, @@ -228,6 +229,7 @@ class EditPartForm(HelperForm): 'link', 'default_location', 'default_supplier', + 'default_expiry', 'units', 'minimum_stock', 'trackable', diff --git a/InvenTree/part/migrations/0061_auto_20210104_2331.py b/InvenTree/part/migrations/0061_auto_20210104_2331.py new file mode 100644 index 0000000000..c40b611b29 --- /dev/null +++ b/InvenTree/part/migrations/0061_auto_20210104_2331.py @@ -0,0 +1,36 @@ +# Generated by Django 3.0.7 on 2021-01-04 12:31 + +import django.core.validators +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('company', '0031_auto_20210103_2215'), + ('part', '0060_merge_20201112_1722'), + ] + + operations = [ + migrations.AddField( + model_name='part', + name='default_expiry', + field=models.PositiveIntegerField(default=0, help_text='Expiry time (in days) for stock items of this part', validators=[django.core.validators.MinValueValidator(0)], verbose_name='Default Expiry'), + ), + migrations.AlterField( + model_name='part', + name='default_supplier', + field=models.ForeignKey(blank=True, help_text='Default supplier part', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='default_parts', to='company.SupplierPart', verbose_name='Default Supplier'), + ), + migrations.AlterField( + model_name='part', + name='minimum_stock', + field=models.PositiveIntegerField(default=0, help_text='Minimum allowed stock level', validators=[django.core.validators.MinValueValidator(0)], verbose_name='Minimum Stock'), + ), + migrations.AlterField( + model_name='part', + name='units', + field=models.CharField(blank=True, default='', help_text='Stock keeping units for this part', max_length=20, null=True, verbose_name='Units'), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index b9d63979e7..390583bd97 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -291,11 +291,12 @@ class Part(MPTTModel): keywords: Optional keywords for improving part search results IPN: Internal part number (optional) revision: Part revision - is_template: If True, this part is a 'template' part and cannot be instantiated as a StockItem + is_template: If True, this part is a 'template' part link: Link to an external page with more information about this part (e.g. internal Wiki) image: Image of this part default_location: Where the item is normally stored (may be null) default_supplier: The default SupplierPart which should be used to procure and stock this part + default_expiry: The default expiry duration for any StockItem instances of this part minimum_stock: Minimum preferred quantity to keep in stock units: Units of measure for this part (default='pcs') salable: Can this part be sold to customers? @@ -722,15 +723,34 @@ class Part(MPTTModel): # Default to None if there are multiple suppliers to choose from return None - default_supplier = models.ForeignKey(SupplierPart, - on_delete=models.SET_NULL, - blank=True, null=True, - help_text=_('Default supplier part'), - related_name='default_parts') + default_supplier = models.ForeignKey( + SupplierPart, + on_delete=models.SET_NULL, + blank=True, null=True, + verbose_name=_('Default Supplier'), + help_text=_('Default supplier part'), + related_name='default_parts' + ) - minimum_stock = models.PositiveIntegerField(default=0, validators=[MinValueValidator(0)], help_text=_('Minimum allowed stock level')) + default_expiry = models.PositiveIntegerField( + default=0, + validators=[MinValueValidator(0)], + verbose_name=_('Default Expiry'), + help_text=_('Expiry time (in days) for stock items of this part'), + ) - units = models.CharField(max_length=20, default="", blank=True, null=True, help_text=_('Stock keeping units for this part')) + minimum_stock = models.PositiveIntegerField( + default=0, validators=[MinValueValidator(0)], + verbose_name=_('Minimum Stock'), + help_text=_('Minimum allowed stock level') + ) + + units = models.CharField( + max_length=20, default="", + blank=True, null=True, + verbose_name=_('Units'), + help_text=_('Stock keeping units for this part') + ) assembly = models.BooleanField( default=False, diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 9711c9fbc8..f723193abb 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -109,6 +109,13 @@ {{ part.minimum_stock }} {% endif %} + {% if part.default_expiry > 0 %} + + + {% trans "Stock Expiry Time" %} + {{ part.default_expiry }} {% trans "days" %} + + {% endif %} {% trans "Creation Date" %}