mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add 'revision' field to part
- e.g. different versions of a product - Can keep old versions in database and mark as inactive
This commit is contained in:
parent
8328e7e13c
commit
a5306ec81b
@ -119,6 +119,7 @@ class PartList(generics.ListCreateAPIView):
|
|||||||
'image',
|
'image',
|
||||||
'name',
|
'name',
|
||||||
'IPN',
|
'IPN',
|
||||||
|
'revision',
|
||||||
'description',
|
'description',
|
||||||
'keywords',
|
'keywords',
|
||||||
'is_template',
|
'is_template',
|
||||||
|
@ -93,6 +93,7 @@ class EditPartForm(HelperForm):
|
|||||||
'name',
|
'name',
|
||||||
'IPN',
|
'IPN',
|
||||||
'description',
|
'description',
|
||||||
|
'revision',
|
||||||
'keywords',
|
'keywords',
|
||||||
'variant_of',
|
'variant_of',
|
||||||
'is_template',
|
'is_template',
|
||||||
|
18
InvenTree/part/migrations/0011_part_revision.py
Normal file
18
InvenTree/part/migrations/0011_part_revision.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 2.2.2 on 2019-06-20 11:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('part', '0010_auto_20190620_2135'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='revision',
|
||||||
|
field=models.CharField(blank=True, help_text='Part revision or version number', max_length=100),
|
||||||
|
),
|
||||||
|
]
|
@ -246,6 +246,9 @@ class Part(models.Model):
|
|||||||
|
|
||||||
elements.append(self.name)
|
elements.append(self.name)
|
||||||
|
|
||||||
|
if self.revision:
|
||||||
|
elements.append(self.revision)
|
||||||
|
|
||||||
return ' | '.join(elements)
|
return ' | '.join(elements)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
@ -278,13 +281,15 @@ class Part(models.Model):
|
|||||||
try:
|
try:
|
||||||
parts = Part.objects.exclude(id=self.id).filter(
|
parts = Part.objects.exclude(id=self.id).filter(
|
||||||
name__iexact=self.name,
|
name__iexact=self.name,
|
||||||
IPN__iexact=self.IPN)
|
IPN__iexact=self.IPN,
|
||||||
|
revision__iexact=self.revision)
|
||||||
|
|
||||||
if parts.exists():
|
if parts.exists():
|
||||||
msg = _("Part must be unique for name, IPN and revision")
|
msg = _("Part must be unique for name, IPN and revision")
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
"name": msg,
|
"name": msg,
|
||||||
"IPN": msg,
|
"IPN": msg,
|
||||||
|
"revision": msg,
|
||||||
})
|
})
|
||||||
except Part.DoesNotExist:
|
except Part.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
@ -325,6 +330,8 @@ class Part(models.Model):
|
|||||||
|
|
||||||
IPN = models.CharField(max_length=100, blank=True, help_text='Internal Part Number')
|
IPN = models.CharField(max_length=100, blank=True, help_text='Internal Part Number')
|
||||||
|
|
||||||
|
revision = models.CharField(max_length=100, blank=True, help_text='Part revision or version number')
|
||||||
|
|
||||||
URL = models.URLField(blank=True, help_text='Link to extenal URL')
|
URL = models.URLField(blank=True, help_text='Link to extenal URL')
|
||||||
|
|
||||||
image = models.ImageField(upload_to=rename_part_image, max_length=255, null=True, blank=True)
|
image = models.ImageField(upload_to=rename_part_image, max_length=255, null=True, blank=True)
|
||||||
@ -803,6 +810,14 @@ class Part(models.Model):
|
|||||||
item.pk = None
|
item.pk = None
|
||||||
item.save()
|
item.save()
|
||||||
|
|
||||||
|
# Copy the fields that aren't available in the duplicate form
|
||||||
|
self.salable = other.salable
|
||||||
|
self.assembly = other.assembly
|
||||||
|
self.component = other.component
|
||||||
|
self.purchaseable = other.purchaseable
|
||||||
|
self.trackable = other.trackable
|
||||||
|
self.virtual = other.virtual
|
||||||
|
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def export_bom(self, **kwargs):
|
def export_bom(self, **kwargs):
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<table class='table table-striped'>
|
<table class='table table-striped'>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>Part name</b></td>
|
<td><b>Part name</b></td>
|
||||||
<td>{{ part.full_name }}</td>
|
<td>{{ part.name }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% if part.IPN %}
|
{% if part.IPN %}
|
||||||
<tr>
|
<tr>
|
||||||
@ -21,6 +21,12 @@
|
|||||||
<td>{{ part.IPN }}</td>
|
<td>{{ part.IPN }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if part.revision %}
|
||||||
|
<tr>
|
||||||
|
<td><b>Revision</b></td>
|
||||||
|
<td>{{ part.revision }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>Description</b></td>
|
<td><b>Description</b></td>
|
||||||
<td>{{ part.description }}</td>
|
<td>{{ part.description }}</td>
|
||||||
|
@ -126,6 +126,11 @@ function loadPartTable(table, url, options={}) {
|
|||||||
|
|
||||||
name += value;
|
name += value;
|
||||||
|
|
||||||
|
if (row.revision) {
|
||||||
|
name += ' | ';
|
||||||
|
name += row.revision;
|
||||||
|
}
|
||||||
|
|
||||||
if (row.is_template) {
|
if (row.is_template) {
|
||||||
name = '<i>' + name + '</i>';
|
name = '<i>' + name + '</i>';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user