Add "target_date" field to PurchaseOrder

This commit is contained in:
Oliver Walters 2021-01-14 17:28:57 +11:00
parent 9efde9de29
commit 834d9ec9a1
2 changed files with 47 additions and 2 deletions

View File

@ -0,0 +1,28 @@
# Generated by Django 3.0.7 on 2021-01-14 06:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('order', '0040_salesorder_target_date'),
]
operations = [
migrations.AddField(
model_name='purchaseorder',
name='target_date',
field=models.DateField(blank=True, help_text='Expected date for order delivery. Order will be overdue after this date.', null=True, verbose_name='Target Delivery Date'),
),
migrations.AlterField(
model_name='purchaseorder',
name='complete_date',
field=models.DateField(blank=True, help_text='Date order was completed', null=True, verbose_name='Completion Date'),
),
migrations.AlterField(
model_name='purchaseorder',
name='issue_date',
field=models.DateField(blank=True, help_text='Date order was issued', null=True, verbose_name='Issue Date'),
),
]

View File

@ -119,8 +119,11 @@ class PurchaseOrder(Order):
supplier: Reference to the company supplying the goods in the order
supplier_reference: Optional field for supplier order reference code
received_by: User that received the goods
target_date: Expected delivery target date for PurchaseOrder completion (optional)
"""
OVERDUE_FILTER = Q(status__in=PurchaseOrderStatus.OPEN) & ~Q(target_date=None) & Q(target_date__lte=datetime.now().date())
@staticmethod
def filterByDate(queryset, min_date, max_date):
"""
@ -186,9 +189,23 @@ class PurchaseOrder(Order):
related_name='+'
)
issue_date = models.DateField(blank=True, null=True, help_text=_('Date order was issued'))
issue_date = models.DateField(
blank=True, null=True,
verbose_name=_('Issue Date'),
help_text=_('Date order was issued')
)
complete_date = models.DateField(blank=True, null=True, help_text=_('Date order was completed'))
target_date = models.DateField(
blank=True, null=True,
verbose_name=_('Target Delivery Date'),
help_text=_('Expected date for order delivery. Order will be overdue after this date.'),
)
complete_date = models.DateField(
blank=True, null=True,
verbose_name=_('Completion Date'),
help_text=_('Date order was completed')
)
def get_absolute_url(self):
return reverse('po-detail', kwargs={'pk': self.id})