2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-10 05:40:55 +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:
Oliver Walters
2019-06-20 21:46:16 +10:00
parent 8328e7e13c
commit a5306ec81b
6 changed files with 48 additions and 2 deletions

View File

@@ -246,6 +246,9 @@ class Part(models.Model):
elements.append(self.name)
if self.revision:
elements.append(self.revision)
return ' | '.join(elements)
def get_absolute_url(self):
@@ -278,13 +281,15 @@ class Part(models.Model):
try:
parts = Part.objects.exclude(id=self.id).filter(
name__iexact=self.name,
IPN__iexact=self.IPN)
IPN__iexact=self.IPN,
revision__iexact=self.revision)
if parts.exists():
msg = _("Part must be unique for name, IPN and revision")
raise ValidationError({
"name": msg,
"IPN": msg,
"revision": msg,
})
except Part.DoesNotExist:
pass
@@ -325,6 +330,8 @@ class Part(models.Model):
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')
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.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()
def export_bom(self, **kwargs):