mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add "default_expiry" field to Part model
This commit is contained in:
parent
692cee113c
commit
37dcf1c1cf
@ -181,6 +181,7 @@ class EditPartForm(HelperForm):
|
|||||||
'keywords': 'fa-key',
|
'keywords': 'fa-key',
|
||||||
'link': 'fa-link',
|
'link': 'fa-link',
|
||||||
'IPN': 'fa-hashtag',
|
'IPN': 'fa-hashtag',
|
||||||
|
'default_expiry': 'fa-stopwatch',
|
||||||
}
|
}
|
||||||
|
|
||||||
bom_copy = forms.BooleanField(required=False,
|
bom_copy = forms.BooleanField(required=False,
|
||||||
@ -228,6 +229,7 @@ class EditPartForm(HelperForm):
|
|||||||
'link',
|
'link',
|
||||||
'default_location',
|
'default_location',
|
||||||
'default_supplier',
|
'default_supplier',
|
||||||
|
'default_expiry',
|
||||||
'units',
|
'units',
|
||||||
'minimum_stock',
|
'minimum_stock',
|
||||||
'trackable',
|
'trackable',
|
||||||
|
36
InvenTree/part/migrations/0061_auto_20210104_2331.py
Normal file
36
InvenTree/part/migrations/0061_auto_20210104_2331.py
Normal file
@ -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'),
|
||||||
|
),
|
||||||
|
]
|
@ -291,11 +291,12 @@ class Part(MPTTModel):
|
|||||||
keywords: Optional keywords for improving part search results
|
keywords: Optional keywords for improving part search results
|
||||||
IPN: Internal part number (optional)
|
IPN: Internal part number (optional)
|
||||||
revision: Part revision
|
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)
|
link: Link to an external page with more information about this part (e.g. internal Wiki)
|
||||||
image: Image of this part
|
image: Image of this part
|
||||||
default_location: Where the item is normally stored (may be null)
|
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_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
|
minimum_stock: Minimum preferred quantity to keep in stock
|
||||||
units: Units of measure for this part (default='pcs')
|
units: Units of measure for this part (default='pcs')
|
||||||
salable: Can this part be sold to customers?
|
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
|
# Default to None if there are multiple suppliers to choose from
|
||||||
return None
|
return None
|
||||||
|
|
||||||
default_supplier = models.ForeignKey(SupplierPart,
|
default_supplier = models.ForeignKey(
|
||||||
on_delete=models.SET_NULL,
|
SupplierPart,
|
||||||
blank=True, null=True,
|
on_delete=models.SET_NULL,
|
||||||
help_text=_('Default supplier part'),
|
blank=True, null=True,
|
||||||
related_name='default_parts')
|
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(
|
assembly = models.BooleanField(
|
||||||
default=False,
|
default=False,
|
||||||
|
@ -109,6 +109,13 @@
|
|||||||
<td>{{ part.minimum_stock }}</td>
|
<td>{{ part.minimum_stock }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if part.default_expiry > 0 %}
|
||||||
|
<tr>
|
||||||
|
<td><span class='fas fa-stopwatch'></span></td>
|
||||||
|
<td><b>{% trans "Stock Expiry Time" %}</b></td>
|
||||||
|
<td>{{ part.default_expiry }} {% trans "days" %}</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class='fas fa-calendar-alt'></span></td>
|
<td><span class='fas fa-calendar-alt'></span></td>
|
||||||
<td><b>{% trans "Creation Date" %}</b></td>
|
<td><b>{% trans "Creation Date" %}</b></td>
|
||||||
|
Loading…
Reference in New Issue
Block a user