Adds new fields to the SupplierPart model:

- available
- availability_updated
This commit is contained in:
Oliver Walters 2022-06-07 00:34:34 +10:00
parent a8a543755f
commit 59fb2ac21f
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,24 @@
# Generated by Django 3.2.13 on 2022-06-06 14:34
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('company', '0043_manufacturerpartattachment'),
]
operations = [
migrations.AddField(
model_name='supplierpart',
name='availability_updated',
field=models.DateTimeField(help_text='Date of last update of availability data', null=True, verbose_name='Availability Updated'),
),
migrations.AddField(
model_name='supplierpart',
name='available',
field=models.DecimalField(decimal_places=3, default=0, help_text='Quantity available from supplier', max_digits=10, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Available'),
),
]

View File

@ -528,6 +528,18 @@ class SupplierPart(models.Model):
# TODO - Reimplement lead-time as a charfield with special validation (pattern matching).
# lead_time = models.DurationField(blank=True, null=True)
available = models.DecimalField(
max_digits=10, decimal_places=3, default=0,
validators=[MinValueValidator(0)],
verbose_name=_('Available'),
help_text=_('Quantity available from supplier'),
)
availability_updated = models.DateTimeField(
null=True, verbose_name=_('Availability Updated'),
help_text=_('Date of last update of availability data'),
)
@property
def manufacturer_string(self):
"""Format a MPN string for this SupplierPart.