From 3e0b57f10aa199f50652456e1320e19ae2a50889 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 15 May 2023 11:13:38 +1000 Subject: [PATCH] Add "description" field to extra line items (#4815) --- .../migrations/0094_auto_20230514_2331.py | 28 +++++++++++++++++++ InvenTree/order/models.py | 6 ++++ InvenTree/order/serializers.py | 1 + InvenTree/templates/js/translated/order.js | 7 +++++ 4 files changed, 42 insertions(+) create mode 100644 InvenTree/order/migrations/0094_auto_20230514_2331.py diff --git a/InvenTree/order/migrations/0094_auto_20230514_2331.py b/InvenTree/order/migrations/0094_auto_20230514_2331.py new file mode 100644 index 0000000000..31771d09a3 --- /dev/null +++ b/InvenTree/order/migrations/0094_auto_20230514_2331.py @@ -0,0 +1,28 @@ +# Generated by Django 3.2.19 on 2023-05-14 23:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('order', '0093_auto_20230426_0248'), + ] + + operations = [ + migrations.AddField( + model_name='purchaseorderextraline', + name='description', + field=models.CharField(blank=True, help_text='Line item description (optional)', max_length=250, verbose_name='Description'), + ), + migrations.AddField( + model_name='returnorderextraline', + name='description', + field=models.CharField(blank=True, help_text='Line item description (optional)', max_length=250, verbose_name='Description'), + ), + migrations.AddField( + model_name='salesorderextraline', + name='description', + field=models.CharField(blank=True, help_text='Line item description (optional)', max_length=250, verbose_name='Description'), + ), + ] diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 9397063ac3..ca91d7d2a3 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -1109,6 +1109,12 @@ class OrderExtraLine(OrderLineItem): """Metaclass options. Abstract ensures no database table is created.""" abstract = True + description = models.CharField( + max_length=250, blank=True, + verbose_name=_('Description'), + help_text=_('Line item description (optional)') + ) + context = models.JSONField( blank=True, null=True, verbose_name=_('Context'), diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index fa315149ba..c0b359e04b 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -147,6 +147,7 @@ class AbstractExtraLineMeta: fields = [ 'pk', + 'description', 'quantity', 'reference', 'notes', diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index dace390ff4..af49ecf57c 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -31,6 +31,7 @@ function extraLineFields(options={}) { }, quantity: {}, reference: {}, + description: {}, price: { icon: 'fa-dollar-sign', }, @@ -272,6 +273,12 @@ function loadExtraLineTable(options={}) { title: '{% trans "Reference" %}', switchable: false, }, + { + sortable: false, + switchable: true, + field: 'description', + title: '{% trans "Description" %}', + }, { sortable: true, switchable: false,