mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Cleverer rendering of sales order allocations
This commit is contained in:
parent
b70e79b778
commit
2972aec759
@ -159,8 +159,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sub-table {
|
.sub-table {
|
||||||
margin-left: 25px;
|
margin-left: 45px;
|
||||||
margin-right: 25px;
|
margin-right: 45px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-icon .glyphicon {
|
.detail-icon .glyphicon {
|
||||||
|
@ -341,6 +341,7 @@ class SOLineItemList(generics.ListCreateAPIView):
|
|||||||
'part',
|
'part',
|
||||||
'part__stock_items',
|
'part__stock_items',
|
||||||
'allocations',
|
'allocations',
|
||||||
|
'allocations__item__location',
|
||||||
'order',
|
'order',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -452,6 +452,13 @@ class SalesOrderAllocation(models.Model):
|
|||||||
|
|
||||||
quantity = RoundingDecimalField(max_digits=15, decimal_places=5, validators=[MinValueValidator(0)], default=1)
|
quantity = RoundingDecimalField(max_digits=15, decimal_places=5, validators=[MinValueValidator(0)], default=1)
|
||||||
|
|
||||||
|
def get_allocated(self):
|
||||||
|
""" String representation of the allocated quantity """
|
||||||
|
if self.item.serial and self.quantity == 1:
|
||||||
|
return "# {sn}".format(sn=self.item.serial)
|
||||||
|
else:
|
||||||
|
return self.quantity
|
||||||
|
|
||||||
def get_location(self):
|
def get_location(self):
|
||||||
return self.item.location.id if self.item.location else None
|
return self.item.location.id if self.item.location else None
|
||||||
|
|
||||||
|
@ -153,6 +153,7 @@ class SalesOrderAllocationSerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
location_path = serializers.CharField(source='get_location_path')
|
location_path = serializers.CharField(source='get_location_path')
|
||||||
location_id = serializers.IntegerField(source='get_location')
|
location_id = serializers.IntegerField(source='get_location')
|
||||||
|
allocated = serializers.CharField(source='get_allocated')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SalesOrderAllocation
|
model = SalesOrderAllocation
|
||||||
@ -160,9 +161,9 @@ class SalesOrderAllocationSerializer(InvenTreeModelSerializer):
|
|||||||
fields = [
|
fields = [
|
||||||
'pk',
|
'pk',
|
||||||
'line',
|
'line',
|
||||||
|
'allocated',
|
||||||
'location_id',
|
'location_id',
|
||||||
'location_path',
|
'location_path',
|
||||||
'quantity',
|
|
||||||
'item',
|
'item',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ $("#so-lines-table").inventreeTable({
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
order: {{ order.id }},
|
order: {{ order.id }},
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
|
allocations: true,
|
||||||
},
|
},
|
||||||
url: "{% url 'api-so-line-list' %}",
|
url: "{% url 'api-so-line-list' %}",
|
||||||
detailView: true,
|
detailView: true,
|
||||||
@ -49,61 +50,39 @@ $("#so-lines-table").inventreeTable({
|
|||||||
return row.allocated > 0;
|
return row.allocated > 0;
|
||||||
},
|
},
|
||||||
detailFormatter: function(index, row, element) {
|
detailFormatter: function(index, row, element) {
|
||||||
inventreeGet("{% url 'api-stock-list' %}",
|
|
||||||
|
var html = `<div class='sub-table'><table class='table table-striped table-condensed' id='allocation-table-${row.pk}'></table></div>`;
|
||||||
|
|
||||||
|
element.html(html);
|
||||||
|
|
||||||
|
$(`#allocation-table-${row.pk}`).bootstrapTable({
|
||||||
|
data: row.allocations,
|
||||||
|
showHeader: false,
|
||||||
|
columns: [
|
||||||
{
|
{
|
||||||
location_detail: true,
|
width: '50%',
|
||||||
sales_order_line: row.pk,
|
field: 'allocated',
|
||||||
|
title: 'Quantity',
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
return renderLink(value, `/stock/item/${row.pk}/`);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
success: function(response) {
|
field: 'location_id',
|
||||||
|
title: 'Location',
|
||||||
var html = `<div class='sub-table'><table class='table table-striped table-condensed' id='allocation-table-${row.pk}'></table></div>`;
|
formatter: function(value, row, index, field) {
|
||||||
|
return renderLink(row.location_path, `/stock/location/${row.location_id}/`);
|
||||||
element.html(html);
|
|
||||||
|
|
||||||
$(`#allocation-table-${row.pk}`).bootstrapTable({
|
|
||||||
data: response,
|
|
||||||
showHeader: false,
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
width: '50%',
|
|
||||||
field: 'quantity',
|
|
||||||
title: 'Quantity',
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
var html = '';
|
|
||||||
if (row.serial && row.quantity == 1) {
|
|
||||||
html = `Serial Number: ${row.serial}`;
|
|
||||||
} else {
|
|
||||||
html = `Quantity: ${row.quantity}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return renderLink(html, `/stock/item/${row.pk}/`);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'location',
|
|
||||||
title: 'Location',
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
return renderLink(row.location_detail.pathstring, `/stock/location/${row.location}/`);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'buttons',
|
|
||||||
title: 'Actions',
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
return '';
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
error: function(response) {
|
},
|
||||||
console.log("An error!");
|
{
|
||||||
|
field: 'buttons',
|
||||||
|
title: 'Actions',
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
return '';
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
],
|
||||||
|
});
|
||||||
return "{% trans 'Loading data' %}";
|
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user