Line item links (#4570)

* Add 'link' field to order line and extra line models

* Update serializers

* Update front end forms and tables
This commit is contained in:
Oliver 2023-04-04 00:55:47 +10:00 committed by GitHub
parent 6ebe8c61c5
commit 1622684c22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 99 additions and 3 deletions

View File

@ -0,0 +1,39 @@
# Generated by Django 3.2.18 on 2023-04-03 14:02
import InvenTree.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('order', '0087_alter_salesorder_status'),
]
operations = [
migrations.AddField(
model_name='purchaseorderextraline',
name='link',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external page', verbose_name='Link'),
),
migrations.AddField(
model_name='purchaseorderlineitem',
name='link',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external page', verbose_name='Link'),
),
migrations.AddField(
model_name='returnorderextraline',
name='link',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external page', verbose_name='Link'),
),
migrations.AddField(
model_name='salesorderextraline',
name='link',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external page', verbose_name='Link'),
),
migrations.AddField(
model_name='salesorderlineitem',
name='link',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external page', verbose_name='Link'),
),
]

View File

@ -1050,6 +1050,12 @@ class OrderLineItem(MetadataMixin, models.Model):
notes = models.CharField(max_length=500, blank=True, verbose_name=_('Notes'), help_text=_('Line item notes'))
link = InvenTreeURLField(
blank=True,
verbose_name=_('Link'),
help_text=_('Link to external page')
)
target_date = models.DateField(
blank=True, null=True,
verbose_name=_('Target Date'),
@ -1876,8 +1882,6 @@ class ReturnOrderLineItem(OrderLineItem):
help_text=_('Cost associated with return or repair for this line item'),
)
link = InvenTreeURLField(blank=True, verbose_name=_('Link'), help_text=_('Link to external page'))
class ReturnOrderExtraLine(OrderExtraLine):
"""Model for a single ExtraLine in a ReturnOrder"""

View File

@ -139,6 +139,7 @@ class AbstractExtraLineMeta:
'order_detail',
'price',
'price_currency',
'link',
]
@ -304,6 +305,7 @@ class PurchaseOrderLineItemSerializer(InvenTreeModelSerializer):
'destination_detail',
'target_date',
'total_price',
'link',
]
def __init__(self, *args, **kwargs):
@ -840,6 +842,7 @@ class SalesOrderLineItemSerializer(InvenTreeModelSerializer):
'sale_price_currency',
'shipped',
'target_date',
'link',
]
def __init__(self, *args, **kwargs):
@ -1614,6 +1617,7 @@ class ReturnOrderLineItemSerializer(InvenTreeModelSerializer):
'reference',
'notes',
'target_date',
'link',
]
def __init__(self, *args, **kwargs):

View File

@ -40,6 +40,9 @@ function extraLineFields(options={}) {
notes: {
icon: 'fa-sticky-note',
},
link: {
icon: 'fa-link',
}
};
if (options.order) {
@ -318,6 +321,15 @@ function loadExtraLineTable(options={}) {
field: 'notes',
title: '{% trans "Notes" %}',
},
{
field: 'link',
title: '{% trans "Link" %}',
formatter: function(value) {
if (value) {
return renderLink(value, value);
}
}
},
{
field: 'buttons',
switchable: false,

View File

@ -330,6 +330,9 @@ function poLineItemFields(options={}) {
notes: {
icon: 'fa-sticky-note',
},
link: {
icon: 'fa-link',
}
};
if (options.order) {
@ -2037,6 +2040,15 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
field: 'notes',
title: '{% trans "Notes" %}',
},
{
field: 'link',
title: '{% trans "Link" %}',
formatter: function(value) {
if (value) {
return renderLink(value, value);
}
}
},
{
switchable: false,
field: 'buttons',

View File

@ -371,7 +371,10 @@ function returnOrderLineItemFields(options={}) {
},
notes: {
icon: 'fa-sticky-note',
}
},
link: {
icon: 'fa-link',
},
};
return fields;
@ -714,6 +717,15 @@ function loadReturnOrderLineItemTable(options={}) {
field: 'notes',
title: '{% trans "Notes" %}',
},
{
field: 'link',
title: '{% trans "Link" %}',
formatter: function(value, row) {
if (value) {
return renderLink(value, value);
}
}
},
{
field: 'buttons',
title: '',

View File

@ -149,6 +149,9 @@ function soLineItemFields(options={}) {
notes: {
icon: 'fa-sticky-note',
},
link: {
icon: 'fa-link',
}
};
if (options.order) {
@ -1868,6 +1871,16 @@ function loadSalesOrderLineItemTable(table, options={}) {
title: '{% trans "Notes" %}',
});
columns.push({
field: 'link',
title: '{% trans "Link" %}',
formatter: function(value) {
if (value) {
return renderLink(value, value);
}
}
});
columns.push({
field: 'buttons',
switchable: false,