2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 12:35:46 +00:00

Merge branch 'master' into partial-shipment

# Conflicts:
#	InvenTree/order/serializers.py
This commit is contained in:
Oliver
2021-11-29 22:59:36 +11:00
34 changed files with 597 additions and 351 deletions

View File

@ -0,0 +1,35 @@
# Generated by Django 3.2.5 on 2021-11-28 01:51
import InvenTree.fields
import InvenTree.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('order', '0052_auto_20211014_0631'),
]
operations = [
migrations.AddField(
model_name='purchaseorderattachment',
name='link',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL', null=True, verbose_name='Link'),
),
migrations.AddField(
model_name='salesorderattachment',
name='link',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL', null=True, verbose_name='Link'),
),
migrations.AlterField(
model_name='purchaseorderattachment',
name='attachment',
field=models.FileField(blank=True, help_text='Select file to attach', null=True, upload_to=InvenTree.models.rename_attachment, verbose_name='Attachment'),
),
migrations.AlterField(
model_name='salesorderattachment',
name='attachment',
field=models.FileField(blank=True, help_text='Select file to attach', null=True, upload_to=InvenTree.models.rename_attachment, verbose_name='Attachment'),
),
]

View File

@ -13,7 +13,7 @@ class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('order', '0052_auto_20211014_0631'),
('order', '0053_auto_20211128_0151'),
]
operations = [

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.5 on 2021-11-29 11:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('order', '0058_auto_20211126_1210'),
]
operations = [
migrations.AddField(
model_name='salesordershipment',
name='tracking_number',
field=models.CharField(blank=True, help_text='Shipment tracking information', max_length=100, verbose_name='Tracking Number'),
),
]

View File

@ -971,6 +971,35 @@ class SalesOrderShipment(models.Model):
help_text=_('Shipment notes'),
)
tracking_number = models.CharField(
max_length=100,
blank=True,
unique=False,
verbose_name=_('Tracking Number'),
help_text=_('Shipment tracking information'),
)
@transaction.atomic
def complete_shipment(self):
"""
Complete this particular shipment:
1. Update any stock items associated with this shipment
2. Update the "shipped" quantity of all associated line items
3. Set the "shipment_date" to now
"""
# Iterate through each stock item assigned to this shipment
for allocation in self.allocations.all():
pass
# Update the "shipment" date
self.shipment_date = datetime.now()
self.save()
class SalesOrderAllocation(models.Model):
"""

View File

@ -18,8 +18,8 @@ from rest_framework.serializers import ValidationError
from sql_util.utils import SubqueryCount
from common.settings import currency_code_mappings
from company.serializers import CompanyBriefSerializer, SupplierPartSerializer
from InvenTree.serializers import InvenTreeAttachmentSerializer
from InvenTree.helpers import normalize
from InvenTree.serializers import InvenTreeModelSerializer
@ -35,6 +35,8 @@ from part.serializers import PartBriefSerializer
import stock.models
import stock.serializers
from users.serializers import OwnerSerializer
class POSerializer(InvenTreeModelSerializer):
"""
@ -84,6 +86,8 @@ class POSerializer(InvenTreeModelSerializer):
reference = serializers.CharField(required=True)
responsible_detail = OwnerSerializer(source='responsible', read_only=True, many=False)
class Meta:
model = order.models.PurchaseOrder
@ -98,6 +102,7 @@ class POSerializer(InvenTreeModelSerializer):
'overdue',
'reference',
'responsible',
'responsible_detail',
'supplier',
'supplier_detail',
'supplier_reference',
@ -372,8 +377,6 @@ class POAttachmentSerializer(InvenTreeAttachmentSerializer):
Serializers for the PurchaseOrderAttachment model
"""
attachment = InvenTreeAttachmentSerializerField(required=True)
class Meta:
model = order.models.PurchaseOrderAttachment
@ -381,6 +384,7 @@ class POAttachmentSerializer(InvenTreeAttachmentSerializer):
'pk',
'order',
'attachment',
'link',
'filename',
'comment',
'upload_date',
@ -608,6 +612,7 @@ class SalesOrderShipmentSerializer(InvenTreeModelSerializer):
'shipment_date',
'checked_by',
'reference',
'tracking_number',
'notes',
]
@ -771,8 +776,6 @@ class SOAttachmentSerializer(InvenTreeAttachmentSerializer):
Serializers for the SalesOrderAttachment model
"""
attachment = InvenTreeAttachmentSerializerField(required=True)
class Meta:
model = order.models.SalesOrderAttachment
@ -781,6 +784,7 @@ class SOAttachmentSerializer(InvenTreeAttachmentSerializer):
'order',
'attachment',
'filename',
'link',
'comment',
'upload_date',
]

View File

@ -124,51 +124,16 @@
}
);
loadAttachmentTable(
'{% url "api-po-attachment-list" %}',
{
filters: {
order: {{ order.pk }},
},
onEdit: function(pk) {
var url = `/api/order/po/attachment/${pk}/`;
constructForm(url, {
fields: {
filename: {},
comment: {},
},
onSuccess: reloadAttachmentTable,
title: '{% trans "Edit Attachment" %}',
});
},
onDelete: function(pk) {
constructForm(`/api/order/po/attachment/${pk}/`, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
onSuccess: reloadAttachmentTable,
});
loadAttachmentTable('{% url "api-po-attachment-list" %}', {
filters: {
order: {{ order.pk }},
},
fields: {
order: {
value: {{ order.pk }},
hidden: true,
}
}
);
$("#new-attachment").click(function() {
constructForm('{% url "api-po-attachment-list" %}', {
method: 'POST',
fields: {
attachment: {},
comment: {},
order: {
value: {{ order.pk }},
hidden: true,
},
},
reload: true,
title: '{% trans "Add Attachment" %}',
});
});
loadStockTable($("#stock-table"), {

View File

@ -194,55 +194,21 @@
},
label: 'attachment',
success: function(data, status, xhr) {
location.reload();
reloadAttachmentTable();
}
}
);
loadAttachmentTable(
'{% url "api-so-attachment-list" %}',
{
filters: {
order: {{ order.pk }},
loadAttachmentTable('{% url "api-so-attachment-list" %}', {
filters: {
order: {{ order.pk }},
},
fields: {
order: {
value: {{ order.pk }},
hidden: true,
},
onEdit: function(pk) {
var url = `/api/order/so/attachment/${pk}/`;
constructForm(url, {
fields: {
filename: {},
comment: {},
},
onSuccess: reloadAttachmentTable,
title: '{% trans "Edit Attachment" %}',
});
},
onDelete: function(pk) {
constructForm(`/api/order/so/attachment/${pk}/`, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
onSuccess: reloadAttachmentTable,
});
}
}
);
$("#new-attachment").click(function() {
constructForm('{% url "api-so-attachment-list" %}', {
method: 'POST',
fields: {
attachment: {},
comment: {},
order: {
value: {{ order.pk }},
hidden: true
}
},
onSuccess: reloadAttachmentTable,
title: '{% trans "Add Attachment" %}'
});
});
loadBuildTable($("#builds-table"), {