Merge pull request #1698 from SchrodingersGat/po-stock-pricing

Displays "purchase order" column in StockItem table
This commit is contained in:
Oliver 2021-06-21 17:19:38 +10:00 committed by GitHub
commit 044650ca10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 2 deletions

View File

@ -33,6 +33,7 @@ def canAppAccessDatabase():
'createsuperuser', 'createsuperuser',
'wait_for_db', 'wait_for_db',
'prerender', 'prerender',
'rebuild',
'collectstatic', 'collectstatic',
'makemessages', 'makemessages',
'compilemessages', 'compilemessages',

View File

@ -75,7 +75,7 @@ src="{% static 'img/blank_image.png' %}"
<tr> <tr>
<td><span class='fas fa-hashtag'></span></td> <td><span class='fas fa-hashtag'></span></td>
<td>{% trans "Order Reference" %}</td> <td>{% trans "Order Reference" %}</td>
<td>{{ order.reference }}{% include "clip.html"%}</td> <td>{% settings_value 'PURCHASEORDER_REFERENCE_PREFIX' %}{{ order.reference }}{% include "clip.html"%}</td>
</tr> </tr>
<tr> <tr>
<td><span class='fas fa-info'></span></td> <td><span class='fas fa-info'></span></td>

View File

@ -77,7 +77,7 @@ src="{% static 'img/blank_image.png' %}"
<tr> <tr>
<td><span class='fas fa-hashtag'></span></td> <td><span class='fas fa-hashtag'></span></td>
<td>{% trans "Order Reference" %}</td> <td>{% trans "Order Reference" %}</td>
<td>{{ order.reference }}{% include "clip.html"%}</td> <td>{% settings_value 'SALESORDER_REFERENCE_PREFIX' %}{{ order.reference }}{% include "clip.html"%}</td>
</tr> </tr>
<tr> <tr>
<td><span class='fas fa-info'></span></td> <td><span class='fas fa-info'></span></td>

View File

@ -81,6 +81,7 @@ class StockItemSerializer(InvenTreeModelSerializer):
'belongs_to', 'belongs_to',
'build', 'build',
'customer', 'customer',
'purchase_order',
'sales_order', 'sales_order',
'supplier_part', 'supplier_part',
'supplier_part__supplier', 'supplier_part__supplier',
@ -163,6 +164,10 @@ class StockItemSerializer(InvenTreeModelSerializer):
purchase_price = serializers.SerializerMethodField() purchase_price = serializers.SerializerMethodField()
purchase_order_reference = serializers.CharField(source='purchase_order.reference', read_only=True)
sales_order_reference = serializers.CharField(source='sales_order.reference', read_only=True)
def get_purchase_price(self, obj): def get_purchase_price(self, obj):
""" Return purchase_price (Money field) as string (includes currency) """ """ Return purchase_price (Money field) as string (includes currency) """
@ -208,10 +213,13 @@ class StockItemSerializer(InvenTreeModelSerializer):
'packaging', 'packaging',
'part', 'part',
'part_detail', 'part_detail',
'purchase_order',
'purchase_order_reference',
'pk', 'pk',
'quantity', 'quantity',
'required_tests', 'required_tests',
'sales_order', 'sales_order',
'sales_order_reference',
'serial', 'serial',
'stale', 'stale',
'status', 'status',

View File

@ -660,6 +660,27 @@ function loadStockTable(table, options) {
title: '{% trans "Last Updated" %}', title: '{% trans "Last Updated" %}',
sortable: true, sortable: true,
}, },
{
field: 'purchase_order',
title: '{% trans "Purchase Order" %}',
formatter: function(value, row) {
if (!value) {
return '-';
}
var link = `/order/purchase-order/${row.purchase_order}/`;
var text = `${row.purchase_order}`;
if (row.purchase_order_reference) {
var prefix = '{% settings_value "PURCHASEORDER_REFERENCE_PREFIX" %}';
text = prefix + row.purchase_order_reference;
}
return renderLink(text, link);
}
},
{ {
field: 'purchase_price', field: 'purchase_price',
title: '{% trans "Purchase Price" %}', title: '{% trans "Purchase Price" %}',