From 834d9ec9a1cd7f0f066a5f0235758d6846e13138 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 14 Jan 2021 17:28:57 +1100 Subject: [PATCH] Add "target_date" field to PurchaseOrder --- .../migrations/0041_auto_20210114_1728.py | 28 +++++++++++++++++++ InvenTree/order/models.py | 21 ++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 InvenTree/order/migrations/0041_auto_20210114_1728.py diff --git a/InvenTree/order/migrations/0041_auto_20210114_1728.py b/InvenTree/order/migrations/0041_auto_20210114_1728.py new file mode 100644 index 0000000000..09be471433 --- /dev/null +++ b/InvenTree/order/migrations/0041_auto_20210114_1728.py @@ -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'), + ), + ] diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 23d07a0c2e..3a86cf4306 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -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})