mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge remote-tracking branch 'inventree/master'
This commit is contained in:
commit
3b29cd4e6b
@ -13,6 +13,10 @@ from .models import SalesOrder, SalesOrderLineItem
|
|||||||
from .models import SalesOrderAllocation
|
from .models import SalesOrderAllocation
|
||||||
|
|
||||||
|
|
||||||
|
class PurchaseOrderLineItemInlineAdmin(admin.StackedInline):
|
||||||
|
model = PurchaseOrderLineItem
|
||||||
|
|
||||||
|
|
||||||
class PurchaseOrderAdmin(ImportExportModelAdmin):
|
class PurchaseOrderAdmin(ImportExportModelAdmin):
|
||||||
|
|
||||||
list_display = (
|
list_display = (
|
||||||
@ -29,6 +33,10 @@ class PurchaseOrderAdmin(ImportExportModelAdmin):
|
|||||||
'description',
|
'description',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
inlines = [
|
||||||
|
PurchaseOrderLineItemInlineAdmin
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class SalesOrderAdmin(ImportExportModelAdmin):
|
class SalesOrderAdmin(ImportExportModelAdmin):
|
||||||
|
|
||||||
|
@ -826,6 +826,9 @@ class SalesOrderAllocation(models.Model):
|
|||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def get_po(self):
|
||||||
|
return self.item.purchase_order
|
||||||
|
|
||||||
def complete_allocation(self, user):
|
def complete_allocation(self, user):
|
||||||
"""
|
"""
|
||||||
Complete this allocation (called when the parent SalesOrder is marked as "shipped"):
|
Complete this allocation (called when the parent SalesOrder is marked as "shipped"):
|
||||||
|
@ -235,6 +235,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')
|
||||||
serial = serializers.CharField(source='get_serial')
|
serial = serializers.CharField(source='get_serial')
|
||||||
|
po = serializers.CharField(source='get_po')
|
||||||
quantity = serializers.FloatField()
|
quantity = serializers.FloatField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -247,6 +248,7 @@ class SalesOrderAllocationSerializer(InvenTreeModelSerializer):
|
|||||||
'quantity',
|
'quantity',
|
||||||
'location_id',
|
'location_id',
|
||||||
'location_path',
|
'location_path',
|
||||||
|
'po',
|
||||||
'item',
|
'item',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -87,6 +87,9 @@ function showAllocationSubTable(index, row, element) {
|
|||||||
return renderLink(row.location_path, `/stock/location/${row.location_id}/`);
|
return renderLink(row.location_path, `/stock/location/${row.location_id}/`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: 'po'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'buttons',
|
field: 'buttons',
|
||||||
title: '{% trans "Actions" %}',
|
title: '{% trans "Actions" %}',
|
||||||
@ -159,9 +162,12 @@ function showFulfilledSubTable(index, row, element) {
|
|||||||
text = `{% trans "Quantity" %}: ${row.quantity}`;
|
text = `{% trans "Quantity" %}: ${row.quantity}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return renderLink(text, `/stock/item/${row.pk}/`);
|
return renderLink(text, `/stock/item/${row.pk}/`);
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
field: 'po'
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -271,6 +277,25 @@ $("#so-lines-table").inventreeTable({
|
|||||||
field: 'notes',
|
field: 'notes',
|
||||||
title: '{% trans "Notes" %}',
|
title: '{% trans "Notes" %}',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: 'po',
|
||||||
|
title: '{% trans "PO" %}',
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
var po_name = "";
|
||||||
|
if (row.allocated) {
|
||||||
|
row.allocations.forEach(function(allocation) {
|
||||||
|
if (allocation.po != po_name) {
|
||||||
|
if (po_name) {
|
||||||
|
po_name = "-";
|
||||||
|
} else {
|
||||||
|
po_name = allocation.po
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return `<div>` + po_name + `</div>`;
|
||||||
|
}
|
||||||
|
},
|
||||||
{% if order.status == SalesOrderStatus.PENDING %}
|
{% if order.status == SalesOrderStatus.PENDING %}
|
||||||
{
|
{
|
||||||
field: 'buttons',
|
field: 'buttons',
|
||||||
|
@ -90,7 +90,7 @@ class SalesOrderDetail(InvenTreeRoleMixin, DetailView):
|
|||||||
""" Detail view for a SalesOrder object """
|
""" Detail view for a SalesOrder object """
|
||||||
|
|
||||||
context_object_name = 'order'
|
context_object_name = 'order'
|
||||||
queryset = SalesOrder.objects.all().prefetch_related('lines')
|
queryset = SalesOrder.objects.all().prefetch_related('lines__allocations__item__purchase_order')
|
||||||
template_name = 'order/sales_order_detail.html'
|
template_name = 'order/sales_order_detail.html'
|
||||||
|
|
||||||
|
|
||||||
|
@ -1370,6 +1370,12 @@ class StockItem(MPTTModel):
|
|||||||
if self.location:
|
if self.location:
|
||||||
s += ' @ {loc}'.format(loc=self.location.name)
|
s += ' @ {loc}'.format(loc=self.location.name)
|
||||||
|
|
||||||
|
if self.purchase_order:
|
||||||
|
s += " ({pre}{po})".format(
|
||||||
|
pre=helpers.getSetting("PURCHASEORDER_REFERENCE_PREFIX"),
|
||||||
|
po=self.purchase_order,
|
||||||
|
)
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
Loading…
Reference in New Issue
Block a user