mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
rename AdditionalLineItems to ExtraLine
This commit is contained in:
parent
ce68ee3781
commit
bff2fb81f3
@ -8,13 +8,13 @@ from import_export.admin import ImportExportModelAdmin
|
||||
from import_export.resources import ModelResource
|
||||
from import_export.fields import Field
|
||||
|
||||
from .models import PurchaseOrder, PurchaseOrderLineItem, PurchaseOrderAdditionalLineItem
|
||||
from .models import SalesOrder, SalesOrderLineItem, SalesOrderAdditionalLineItem
|
||||
from .models import PurchaseOrder, PurchaseOrderLineItem, PurchaseOrderExtraLine
|
||||
from .models import SalesOrder, SalesOrderLineItem, SalesOrderExtraLine
|
||||
from .models import SalesOrderShipment, SalesOrderAllocation
|
||||
|
||||
|
||||
# region general classes
|
||||
class GeneralAdditionalLineItemAdmin:
|
||||
class GeneralExtraLineAdmin:
|
||||
list_display = (
|
||||
'order',
|
||||
'quantity',
|
||||
@ -30,7 +30,7 @@ class GeneralAdditionalLineItemAdmin:
|
||||
autocomplete_fields = ('order', )
|
||||
|
||||
|
||||
class GeneralAdditionalLineMeta:
|
||||
class GeneralExtraLineMeta:
|
||||
skip_unchanged = True
|
||||
report_skipped = False
|
||||
clean_model_instances = True
|
||||
@ -110,11 +110,11 @@ class POLineItemResource(ModelResource):
|
||||
clean_model_instances = True
|
||||
|
||||
|
||||
class POAdditionalLineItemResource(ModelResource):
|
||||
""" Class for managing import / export of POAdditionalLineItem data """
|
||||
class POExtraLineResource(ModelResource):
|
||||
""" Class for managing import / export of POExtraLine data """
|
||||
|
||||
class Meta(GeneralAdditionalLineMeta):
|
||||
model = PurchaseOrderAdditionalLineItem
|
||||
class Meta(GeneralExtraLineMeta):
|
||||
model = PurchaseOrderExtraLine
|
||||
|
||||
|
||||
class SOLineItemResource(ModelResource):
|
||||
@ -148,11 +148,11 @@ class SOLineItemResource(ModelResource):
|
||||
clean_model_instances = True
|
||||
|
||||
|
||||
class SOAdditionalLineItemResource(ModelResource):
|
||||
""" Class for managing import / export of SOAdditionalLineItem data """
|
||||
class SOExtraLineResource(ModelResource):
|
||||
""" Class for managing import / export of SOExtraLine data """
|
||||
|
||||
class Meta(GeneralAdditionalLineMeta):
|
||||
model = SalesOrderAdditionalLineItem
|
||||
class Meta(GeneralExtraLineMeta):
|
||||
model = SalesOrderExtraLine
|
||||
|
||||
|
||||
class PurchaseOrderLineItemAdmin(ImportExportModelAdmin):
|
||||
@ -171,9 +171,9 @@ class PurchaseOrderLineItemAdmin(ImportExportModelAdmin):
|
||||
autocomplete_fields = ('order', 'part', 'destination',)
|
||||
|
||||
|
||||
class PurchaseOrderAdditionalLineItemAdmin(GeneralAdditionalLineItemAdmin, ImportExportModelAdmin):
|
||||
class PurchaseOrderExtraLineAdmin(GeneralExtraLineAdmin, ImportExportModelAdmin):
|
||||
|
||||
resource_class = POAdditionalLineItemResource
|
||||
resource_class = POExtraLineResource
|
||||
|
||||
|
||||
class SalesOrderLineItemAdmin(ImportExportModelAdmin):
|
||||
@ -197,9 +197,9 @@ class SalesOrderLineItemAdmin(ImportExportModelAdmin):
|
||||
autocomplete_fields = ('order', 'part',)
|
||||
|
||||
|
||||
class SalesOrderAdditionalLineItemAdmin(GeneralAdditionalLineItemAdmin, ImportExportModelAdmin):
|
||||
class SalesOrderExtraLineAdmin(GeneralExtraLineAdmin, ImportExportModelAdmin):
|
||||
|
||||
resource_class = SOAdditionalLineItemResource
|
||||
resource_class = SOExtraLineResource
|
||||
|
||||
|
||||
class SalesOrderShipmentAdmin(ImportExportModelAdmin):
|
||||
@ -232,11 +232,11 @@ class SalesOrderAllocationAdmin(ImportExportModelAdmin):
|
||||
|
||||
admin.site.register(PurchaseOrder, PurchaseOrderAdmin)
|
||||
admin.site.register(PurchaseOrderLineItem, PurchaseOrderLineItemAdmin)
|
||||
admin.site.register(PurchaseOrderAdditionalLineItem, PurchaseOrderAdditionalLineItemAdmin)
|
||||
admin.site.register(PurchaseOrderExtraLine, PurchaseOrderExtraLineAdmin)
|
||||
|
||||
admin.site.register(SalesOrder, SalesOrderAdmin)
|
||||
admin.site.register(SalesOrderLineItem, SalesOrderLineItemAdmin)
|
||||
admin.site.register(SalesOrderAdditionalLineItem, SalesOrderAdditionalLineItemAdmin)
|
||||
admin.site.register(SalesOrderExtraLine, SalesOrderExtraLineAdmin)
|
||||
|
||||
admin.site.register(SalesOrderShipment, SalesOrderShipmentAdmin)
|
||||
admin.site.register(SalesOrderAllocation, SalesOrderAllocationAdmin)
|
||||
|
@ -27,9 +27,9 @@ from part.models import Part
|
||||
from users.models import Owner
|
||||
|
||||
|
||||
class GeneralAdditionalLineItemList:
|
||||
class GeneralExtraLineList:
|
||||
"""
|
||||
General template for AdditionalLineItem API classes
|
||||
General template for ExtraLine API classes
|
||||
"""
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
@ -501,20 +501,20 @@ class POLineItemDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
return queryset
|
||||
|
||||
|
||||
class POAdditionalLineItemList(GeneralAdditionalLineItemList, generics.ListCreateAPIView):
|
||||
class POExtraLineList(GeneralExtraLineList, generics.ListCreateAPIView):
|
||||
"""
|
||||
API endpoint for accessing a list of PurchaseOrderAdditionalLineItem objects.
|
||||
API endpoint for accessing a list of PurchaseOrderExtraLine objects.
|
||||
"""
|
||||
|
||||
queryset = models.PurchaseOrderAdditionalLineItem.objects.all()
|
||||
serializer_class = serializers.POAdditionalLineItemSerializer
|
||||
queryset = models.PurchaseOrderExtraLine.objects.all()
|
||||
serializer_class = serializers.POExtraLineSerializer
|
||||
|
||||
|
||||
class POAdditionalLineItemDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
""" API endpoint for detail view of a PurchaseOrderAdditionalLineItem object """
|
||||
class POExtraLineDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
""" API endpoint for detail view of a PurchaseOrderExtraLine object """
|
||||
|
||||
queryset = models.PurchaseOrderAdditionalLineItem.objects.all()
|
||||
serializer_class = serializers.POAdditionalLineItemSerializer
|
||||
queryset = models.PurchaseOrderExtraLine.objects.all()
|
||||
serializer_class = serializers.POExtraLineSerializer
|
||||
|
||||
|
||||
class SOAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
|
||||
@ -811,20 +811,20 @@ class SOLineItemList(generics.ListCreateAPIView):
|
||||
]
|
||||
|
||||
|
||||
class SOAdditionalLineItemList(GeneralAdditionalLineItemList, generics.ListCreateAPIView):
|
||||
class SOExtraLineList(GeneralExtraLineList, generics.ListCreateAPIView):
|
||||
"""
|
||||
API endpoint for accessing a list of SalesOrderAdditionalLineItem objects.
|
||||
API endpoint for accessing a list of SalesOrderExtraLine objects.
|
||||
"""
|
||||
|
||||
queryset = models.SalesOrderAdditionalLineItem.objects.all()
|
||||
serializer_class = serializers.SOAdditionalLineItemSerializer
|
||||
queryset = models.SalesOrderExtraLine.objects.all()
|
||||
serializer_class = serializers.SOExtraLineSerializer
|
||||
|
||||
|
||||
class SOAdditionalLineItemDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
""" API endpoint for detail view of a SalesOrderAdditionalLineItem object """
|
||||
class SOExtraLineDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
""" API endpoint for detail view of a SalesOrderExtraLine object """
|
||||
|
||||
queryset = models.SalesOrderAdditionalLineItem.objects.all()
|
||||
serializer_class = serializers.SOAdditionalLineItemSerializer
|
||||
queryset = models.SalesOrderExtraLine.objects.all()
|
||||
serializer_class = serializers.SOExtraLineSerializer
|
||||
|
||||
|
||||
class SOLineItemDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
@ -1120,10 +1120,10 @@ order_api_urls = [
|
||||
url(r'^.*$', POLineItemList.as_view(), name='api-po-line-list'),
|
||||
])),
|
||||
|
||||
# API endpoints for purchase order additional line items
|
||||
url(r'^po-additional-line/', include([
|
||||
url(r'^(?P<pk>\d+)/$', POAdditionalLineItemDetail.as_view(), name='api-po-additional-line-detail'),
|
||||
url(r'^$', POAdditionalLineItemList.as_view(), name='api-po-additional-line-list'),
|
||||
# API endpoints for purchase order extra line
|
||||
url(r'^po-extra-line/', include([
|
||||
url(r'^(?P<pk>\d+)/$', POExtraLineDetail.as_view(), name='api-po-extra-line-detail'),
|
||||
url(r'^$', POExtraLineList.as_view(), name='api-po-extra-line-list'),
|
||||
])),
|
||||
|
||||
# API endpoints for sales ordesr
|
||||
@ -1159,10 +1159,10 @@ order_api_urls = [
|
||||
url(r'^$', SOLineItemList.as_view(), name='api-so-line-list'),
|
||||
])),
|
||||
|
||||
# API endpoints for sales order additional line items
|
||||
url(r'^so-additional-line/', include([
|
||||
url(r'^(?P<pk>\d+)/$', SOAdditionalLineItemDetail.as_view(), name='api-so-additional-line-detail'),
|
||||
url(r'^$', SOAdditionalLineItemList.as_view(), name='api-so-additional-line-list'),
|
||||
# API endpoints for sales order extra line
|
||||
url(r'^so-extra-line/', include([
|
||||
url(r'^(?P<pk>\d+)/$', SOExtraLineDetail.as_view(), name='api-so-extra-line-detail'),
|
||||
url(r'^$', SOExtraLineList.as_view(), name='api-so-extra-line-list'),
|
||||
])),
|
||||
|
||||
# API endpoints for sales order allocations
|
||||
|
@ -163,8 +163,8 @@ class Order(ReferenceIndexingMixin):
|
||||
# order items
|
||||
total += sum([a.quantity * convert_money(getattr(a, price_ref), target_currency) for a in self.lines.all() if getattr(a, price_ref)])
|
||||
|
||||
# additional lines
|
||||
total += sum([a.quantity * convert_money(a.sale_price, target_currency) for a in self.additional_lines.all() if a.sale_price])
|
||||
# extra lines
|
||||
total += sum([a.quantity * convert_money(a.price, target_currency) for a in self.extra_lines.all() if a.price])
|
||||
|
||||
# set decimal-places
|
||||
total.decimal_places = 4
|
||||
@ -875,11 +875,11 @@ class OrderLineItem(models.Model):
|
||||
)
|
||||
|
||||
|
||||
class OrderAdditionalLineItem(OrderLineItem):
|
||||
class OrderExtraLine(OrderLineItem):
|
||||
"""
|
||||
Abstract Model for a single AdditionalLineItem in a Order
|
||||
Abstract Model for a single ExtraLine in a Order
|
||||
Attributes:
|
||||
sale_price: The unit sale price for this OrderLineItem
|
||||
price: The unit sale price for this OrderLineItem
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
@ -887,18 +887,18 @@ class OrderAdditionalLineItem(OrderLineItem):
|
||||
unique_together = [
|
||||
]
|
||||
|
||||
sale_price = InvenTreeModelMoneyField(
|
||||
price = InvenTreeModelMoneyField(
|
||||
max_digits=19,
|
||||
decimal_places=4,
|
||||
null=True, blank=True,
|
||||
verbose_name=_('Sale Price'),
|
||||
help_text=_('Unit sale price'),
|
||||
verbose_name=_('Price'),
|
||||
help_text=_('Unit price'),
|
||||
)
|
||||
|
||||
def sale_price_converted(self):
|
||||
return convert_money(self.sale_price, currency_code_default())
|
||||
def price_converted(self):
|
||||
return convert_money(self.price, currency_code_default())
|
||||
|
||||
def sale_price_converted_currency(self):
|
||||
def price_converted_currency(self):
|
||||
return currency_code_default()
|
||||
|
||||
|
||||
@ -1011,19 +1011,19 @@ class PurchaseOrderLineItem(OrderLineItem):
|
||||
return max(r, 0)
|
||||
|
||||
|
||||
class PurchaseOrderAdditionalLineItem(OrderAdditionalLineItem):
|
||||
class PurchaseOrderExtraLine(OrderExtraLine):
|
||||
"""
|
||||
Model for a single AdditionalLineItem in a PurchaseOrder
|
||||
Model for a single ExtraLine in a PurchaseOrder
|
||||
Attributes:
|
||||
order: Link to the PurchaseOrder that this line item belongs to
|
||||
title: title of line item
|
||||
sale_price: The unit sale price for this OrderLineItem
|
||||
order: Link to the PurchaseOrder that this line belongs to
|
||||
title: title of line
|
||||
price: The unit price for this OrderLine
|
||||
"""
|
||||
@staticmethod
|
||||
def get_api_url():
|
||||
return reverse('api-po-additional-line-list')
|
||||
return reverse('api-po-extra-line-list')
|
||||
|
||||
order = models.ForeignKey(PurchaseOrder, on_delete=models.CASCADE, related_name='additional_lines', verbose_name=_('Order'), help_text=_('Purchase Order'))
|
||||
order = models.ForeignKey(PurchaseOrder, on_delete=models.CASCADE, related_name='extra_lines', verbose_name=_('Order'), help_text=_('Purchase Order'))
|
||||
|
||||
|
||||
class SalesOrderLineItem(OrderLineItem):
|
||||
@ -1229,19 +1229,19 @@ class SalesOrderShipment(models.Model):
|
||||
trigger_event('salesordershipment.completed', id=self.pk)
|
||||
|
||||
|
||||
class SalesOrderAdditionalLineItem(OrderAdditionalLineItem):
|
||||
class SalesOrderExtraLine(OrderExtraLine):
|
||||
"""
|
||||
Model for a single AdditionalLineItem in a SalesOrder
|
||||
Model for a single ExtraLine in a SalesOrder
|
||||
Attributes:
|
||||
order: Link to the SalesOrder that this line item belongs to
|
||||
title: title of line item
|
||||
sale_price: The unit sale price for this OrderLineItem
|
||||
order: Link to the SalesOrder that this line belongs to
|
||||
title: title of line
|
||||
price: The unit price for this OrderLine
|
||||
"""
|
||||
@staticmethod
|
||||
def get_api_url():
|
||||
return reverse('api-so-additional-line-list')
|
||||
return reverse('api-so-extra-line-list')
|
||||
|
||||
order = models.ForeignKey(SalesOrder, on_delete=models.CASCADE, related_name='additional_lines', verbose_name=_('Order'), help_text=_('Sales Order'))
|
||||
order = models.ForeignKey(SalesOrder, on_delete=models.CASCADE, related_name='extra_lines', verbose_name=_('Order'), help_text=_('Sales Order'))
|
||||
|
||||
|
||||
class SalesOrderAllocation(models.Model):
|
||||
|
@ -53,8 +53,8 @@ class AbstractOrderSerializer(serializers.Serializer):
|
||||
total_price_string = serializers.CharField(source='get_total_price', read_only=True)
|
||||
|
||||
|
||||
class AbstractAdditionalLineItemSerializer(serializers.Serializer):
|
||||
""" Abstract Serializer for a AdditionalLineItem object """
|
||||
class AbstractExtraLineSerializer(serializers.Serializer):
|
||||
""" Abstract Serializer for a ExtraLine object """
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
order_detail = kwargs.pop('order_detail', False)
|
||||
@ -66,21 +66,21 @@ class AbstractAdditionalLineItemSerializer(serializers.Serializer):
|
||||
|
||||
quantity = serializers.FloatField()
|
||||
|
||||
sale_price = InvenTreeMoneySerializer(
|
||||
price = InvenTreeMoneySerializer(
|
||||
allow_null=True
|
||||
)
|
||||
|
||||
sale_price_string = serializers.CharField(source='sale_price', read_only=True)
|
||||
price_string = serializers.CharField(source='price', read_only=True)
|
||||
|
||||
sale_price_currency = serializers.ChoiceField(
|
||||
price_currency = serializers.ChoiceField(
|
||||
choices=currency_code_mappings(),
|
||||
help_text=_('Sale price currency'),
|
||||
help_text=_('Price currency'),
|
||||
)
|
||||
|
||||
|
||||
class AbstractAdditionalLineItemMeta:
|
||||
class AbstractExtraLineMeta:
|
||||
"""
|
||||
Abstract Meta for LineItem
|
||||
Abstract Meta for ExtraLine
|
||||
"""
|
||||
|
||||
fields = [
|
||||
@ -90,9 +90,9 @@ class AbstractAdditionalLineItemMeta:
|
||||
'notes',
|
||||
'order',
|
||||
'order_detail',
|
||||
'sale_price',
|
||||
'sale_price_currency',
|
||||
'sale_price_string',
|
||||
'price',
|
||||
'price_currency',
|
||||
'price_string',
|
||||
]
|
||||
|
||||
|
||||
@ -272,13 +272,13 @@ class POLineItemSerializer(InvenTreeModelSerializer):
|
||||
]
|
||||
|
||||
|
||||
class POAdditionalLineItemSerializer(AbstractAdditionalLineItemSerializer, InvenTreeModelSerializer):
|
||||
""" Serializer for a PurchaseOrderAdditionalLineItem object """
|
||||
class POExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer):
|
||||
""" Serializer for a PurchaseOrderExtraLine object """
|
||||
|
||||
order_detail = POSerializer(source='order', many=False, read_only=True)
|
||||
|
||||
class Meta(AbstractAdditionalLineItemMeta):
|
||||
model = order.models.PurchaseOrderAdditionalLineItem
|
||||
class Meta(AbstractExtraLineMeta):
|
||||
model = order.models.PurchaseOrderExtraLine
|
||||
|
||||
|
||||
class POLineItemReceiveSerializer(serializers.Serializer):
|
||||
@ -1168,13 +1168,13 @@ class SOShipmentAllocationSerializer(serializers.Serializer):
|
||||
)
|
||||
|
||||
|
||||
class SOAdditionalLineItemSerializer(AbstractAdditionalLineItemSerializer, InvenTreeModelSerializer):
|
||||
""" Serializer for a SalesOrderAdditionalLineItem object """
|
||||
class SOExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer):
|
||||
""" Serializer for a SalesOrderExtraLine object """
|
||||
|
||||
order_detail = SalesOrderSerializer(source='order', many=False, read_only=True)
|
||||
|
||||
class Meta(AbstractAdditionalLineItemMeta):
|
||||
model = order.models.SalesOrderAdditionalLineItem
|
||||
class Meta(AbstractExtraLineMeta):
|
||||
model = order.models.SalesOrderExtraLine
|
||||
|
||||
|
||||
class SOAttachmentSerializer(InvenTreeAttachmentSerializer):
|
||||
|
@ -46,24 +46,24 @@
|
||||
|
||||
<div class='panel-heading'>
|
||||
<div class='d-flex flex-wrap'>
|
||||
<h4>{% trans "Additional Order Items" %}</h4>
|
||||
<h4>{% trans "Extra Lines" %}</h4>
|
||||
{% include "spacer.html" %}
|
||||
<div class='btn-group' role='group'>
|
||||
{% if roles.purchase_order.change and order.status == PurchaseOrderStatus.PENDING %}
|
||||
<button type='button' class='btn btn-success' id='new-po-additional-line'>
|
||||
<span class='fas fa-plus-circle'></span> {% trans "Add Additional Order Items" %}
|
||||
<button type='button' class='btn btn-success' id='new-po-extra-line'>
|
||||
<span class='fas fa-plus-circle'></span> {% trans "Add Extra Line" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='panel-content'>
|
||||
<div id='order-additional-toolbar-buttons' class='btn-group' style='float: right;'>
|
||||
<div id='order-extra-toolbar-buttons' class='btn-group' style='float: right;'>
|
||||
<div class='btn-group'>
|
||||
{% include "filter_list.html" with id="purchase-order-additional-lines" %}
|
||||
{% include "filter_list.html" with id="purchase-order-extra-lines" %}
|
||||
</div>
|
||||
</div>
|
||||
<table class='table table-striped table-condensed' id='po-additional-lines-table' data-toolbar='#order-additional-toolbar-buttons'>
|
||||
<table class='table table-striped table-condensed' id='po-extra-lines-table' data-toolbar='#order-extra-toolbar-buttons'>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@ -230,24 +230,24 @@ loadPurchaseOrderLineItemTable('#po-line-table', {
|
||||
{% endif %}
|
||||
});
|
||||
|
||||
$("#new-po-additional-line").click(function() {
|
||||
$("#new-po-extra-line").click(function() {
|
||||
|
||||
var fields = additionalLineItemFields({
|
||||
var fields = extraLineFields({
|
||||
order: {{ order.pk }},
|
||||
});
|
||||
|
||||
constructForm('{% url "api-po-additional-line-list" %}', {
|
||||
constructForm('{% url "api-po-extra-line-list" %}', {
|
||||
fields: fields,
|
||||
method: 'POST',
|
||||
title: '{% trans "Add Order Line" %}',
|
||||
onSuccess: function() {
|
||||
$("#po-additional-lines-table").bootstrapTable("refresh");
|
||||
$("#po-extra-lines-table").bootstrapTable("refresh");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
loadPurchaseOrderAdditionalLineItemTable(
|
||||
'#po-additional-lines-table',
|
||||
loadPurchaseOrderExtraLineTable(
|
||||
'#po-extra-lines-table',
|
||||
{
|
||||
order: {{ order.pk }},
|
||||
status: {{ order.status }},
|
||||
|
@ -38,24 +38,24 @@
|
||||
|
||||
<div class='panel-heading'>
|
||||
<div class='d-flex flex-wrap'>
|
||||
<h4>{% trans "Additional Order Items" %}</h4>
|
||||
<h4>{% trans "Extra Lines" %}</h4>
|
||||
{% include "spacer.html" %}
|
||||
<div class='btn-group' role='group'>
|
||||
{% if roles.sales_order.change and order.is_pending %}
|
||||
<button type='button' class='btn btn-success' id='new-so-additional-line'>
|
||||
<span class='fas fa-plus-circle'></span> {% trans "Add Additional Order Items" %}
|
||||
<button type='button' class='btn btn-success' id='new-so-extra-line'>
|
||||
<span class='fas fa-plus-circle'></span> {% trans "Add Extra Line" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='panel-content'>
|
||||
<div id='order-additional-toolbar-buttons' class='btn-group' style='float: right;'>
|
||||
<div id='order-extra-toolbar-buttons' class='btn-group' style='float: right;'>
|
||||
<div class='btn-group'>
|
||||
{% include "filter_list.html" with id="sales-order-additional-lines" %}
|
||||
{% include "filter_list.html" with id="sales-order-extra-lines" %}
|
||||
</div>
|
||||
</div>
|
||||
<table class='table table-striped table-condensed' id='so-additional-lines-table' data-toolbar='#order-additional-toolbar-buttons'>
|
||||
<table class='table table-striped table-condensed' id='so-extra-lines-table' data-toolbar='#order-extra-toolbar-buttons'>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@ -268,24 +268,24 @@
|
||||
}
|
||||
);
|
||||
|
||||
$("#new-so-additional-line").click(function() {
|
||||
$("#new-so-extra-line").click(function() {
|
||||
|
||||
var fields = AdditionalLineItemFields({
|
||||
var fields = ExtraLineFields({
|
||||
order: {{ order.pk }},
|
||||
});
|
||||
|
||||
constructForm('{% url "api-so-additional-line-list" %}', {
|
||||
constructForm('{% url "api-so-extra-line-list" %}', {
|
||||
fields: fields,
|
||||
method: 'POST',
|
||||
title: '{% trans "Add Order Line" %}',
|
||||
title: '{% trans "Add Extra Line" %}',
|
||||
onSuccess: function() {
|
||||
$("#so-additional-lines-table").bootstrapTable("refresh");
|
||||
$("#so-extra-lines-table").bootstrapTable("refresh");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
loadSalesOrderAdditionalLineItemTable(
|
||||
'#so-additional-lines-table',
|
||||
loadSalesOrderExtraLineTable(
|
||||
'#so-extra-lines-table',
|
||||
{
|
||||
order: {{ order.pk }},
|
||||
status: {{ order.status }},
|
||||
|
@ -466,7 +466,7 @@ class PurchaseOrderReport(ReportTemplateBase):
|
||||
return {
|
||||
'description': order.description,
|
||||
'lines': order.lines,
|
||||
'additional_lines': order.additional_lines,
|
||||
'extra_lines': order.extra_lines,
|
||||
'order': order,
|
||||
'reference': order.reference,
|
||||
'supplier': order.supplier,
|
||||
@ -506,7 +506,7 @@ class SalesOrderReport(ReportTemplateBase):
|
||||
'customer': order.customer,
|
||||
'description': order.description,
|
||||
'lines': order.lines,
|
||||
'additional_lines': order.additional_lines,
|
||||
'extra_lines': order.extra_lines,
|
||||
'order': order,
|
||||
'prefix': common.models.InvenTreeSetting.get_setting('SALESORDER_REFERENCE_PREFIX'),
|
||||
'reference': order.reference,
|
||||
|
@ -26,11 +26,11 @@
|
||||
editPurchaseOrderLineItem,
|
||||
exportOrder,
|
||||
loadPurchaseOrderLineItemTable,
|
||||
loadPurchaseOrderAdditionalLineItemTable
|
||||
loadPurchaseOrderExtraLineTable
|
||||
loadPurchaseOrderTable,
|
||||
loadSalesOrderAllocationTable,
|
||||
loadSalesOrderLineItemTable,
|
||||
loadSalesOrderAdditionalLineItemTable
|
||||
loadSalesOrderExtraLineTable
|
||||
loadSalesOrderShipmentTable,
|
||||
loadSalesOrderTable,
|
||||
newPurchaseOrderFromOrderWizard,
|
||||
@ -38,7 +38,7 @@
|
||||
removeOrderRowFromOrderWizard,
|
||||
removePurchaseOrderLineItem,
|
||||
loadOrderTotal,
|
||||
additionalLineItemFields,
|
||||
ExtraLineFields,
|
||||
*/
|
||||
|
||||
|
||||
@ -309,8 +309,8 @@ function soLineItemFields(options={}) {
|
||||
}
|
||||
|
||||
|
||||
/* Construct a set of fields for a OrderAdditionalLineItem form */
|
||||
function additionalLineItemFields(options={}) {
|
||||
/* Construct a set of fields for a OrderExtraLine form */
|
||||
function extraLineFields(options={}) {
|
||||
|
||||
var fields = {
|
||||
order: {
|
||||
@ -318,8 +318,8 @@ function additionalLineItemFields(options={}) {
|
||||
},
|
||||
quantity: {},
|
||||
reference: {},
|
||||
sale_price: {},
|
||||
sale_price_currency: {},
|
||||
price: {},
|
||||
price_currency: {},
|
||||
notes: {},
|
||||
};
|
||||
|
||||
@ -1400,14 +1400,14 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
|
||||
|
||||
|
||||
/**
|
||||
* Load a table displaying line items for a particular PurchaseOrder
|
||||
* Load a table displaying lines for a particular PurchaseOrder
|
||||
*
|
||||
* @param {String} table : HTML ID tag e.g. '#table'
|
||||
* @param {Object} options : object which contains:
|
||||
* - order {integer} : pk of the PurchaseOrder
|
||||
* - status: {integer} : status code for the order
|
||||
*/
|
||||
function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
|
||||
function loadPurchaseOrderExtraLineTable(table, options={}) {
|
||||
|
||||
options.table = table;
|
||||
|
||||
@ -1427,17 +1427,17 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
|
||||
options.params.part_detail = true;
|
||||
options.params.allocations = true;
|
||||
|
||||
var filters = loadTableFilters('purchaseorderadditionallineitem');
|
||||
var filters = loadTableFilters('purchaseorderextraline');
|
||||
|
||||
for (var key in options.params) {
|
||||
filters[key] = options.params[key];
|
||||
}
|
||||
|
||||
options.url = options.url || '{% url "api-po-additional-line-list" %}';
|
||||
options.url = options.url || '{% url "api-po-extra-line-list" %}';
|
||||
|
||||
var filter_target = options.filter_target || '#filter-list-purchase-order-additional-lines';
|
||||
var filter_target = options.filter_target || '#filter-list-purchase-order-extra-lines';
|
||||
|
||||
setupFilterList('purchaseorderadditionallineitem', $(table), filter_target);
|
||||
setupFilterList('purchaseorderextraline', $(table), filter_target);
|
||||
|
||||
// Is the order pending?
|
||||
var pending = options.status == {{ SalesOrderStatus.PENDING }};
|
||||
@ -1465,18 +1465,18 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'sale_price',
|
||||
field: 'price',
|
||||
title: '{% trans "Unit Price" %}',
|
||||
formatter: function(value, row) {
|
||||
var formatter = new Intl.NumberFormat(
|
||||
'en-US',
|
||||
{
|
||||
style: 'currency',
|
||||
currency: row.sale_price_currency
|
||||
currency: row.price_currency
|
||||
}
|
||||
);
|
||||
|
||||
return formatter.format(row.sale_price);
|
||||
return formatter.format(row.price);
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1488,20 +1488,20 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
|
||||
'en-US',
|
||||
{
|
||||
style: 'currency',
|
||||
currency: row.sale_price_currency
|
||||
currency: row.price_currency
|
||||
}
|
||||
);
|
||||
|
||||
return formatter.format(row.sale_price * row.quantity);
|
||||
return formatter.format(row.price * row.quantity);
|
||||
},
|
||||
footerFormatter: function(data) {
|
||||
var total = data.map(function(row) {
|
||||
return +row['sale_price'] * row['quantity'];
|
||||
return +row['price'] * row['quantity'];
|
||||
}).reduce(function(sum, i) {
|
||||
return sum + i;
|
||||
}, 0);
|
||||
|
||||
var currency = (data.slice(-1)[0] && data.slice(-1)[0].sale_price_currency) || 'USD';
|
||||
var currency = (data.slice(-1)[0] && data.slice(-1)[0].price_currency) || 'USD';
|
||||
|
||||
var formatter = new Intl.NumberFormat(
|
||||
'en-US',
|
||||
@ -1531,12 +1531,12 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
|
||||
|
||||
var pk = row.pk;
|
||||
|
||||
html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line item" %}');
|
||||
html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line item" %}');
|
||||
html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line" %}');
|
||||
html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line" %}');
|
||||
|
||||
var title = '{% trans "Delete line item" %}';
|
||||
var title = '{% trans "Delete line" %}';
|
||||
|
||||
// Prevent deletion of the line item if items have been allocated or shipped!
|
||||
// Prevent deletion of the line if items have been allocated or shipped!
|
||||
html += makeIconButton('fa-trash-alt icon-red', 'button-delete', pk, title, );
|
||||
|
||||
html += `</div>`;
|
||||
@ -1554,20 +1554,20 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
|
||||
// Configure callback functions once the table is loaded
|
||||
function setupCallbacks() {
|
||||
|
||||
// Callback for duplicating line items
|
||||
// Callback for duplicating lines
|
||||
$(table).find('.button-duplicate').click(function() {
|
||||
var pk = $(this).attr('pk');
|
||||
|
||||
inventreeGet(`/api/order/po-additional-line/${pk}/`, {}, {
|
||||
inventreeGet(`/api/order/po-extra-line/${pk}/`, {}, {
|
||||
success: function(data) {
|
||||
|
||||
var fields = additionalLineItemFields();
|
||||
var fields = extraLineFields();
|
||||
|
||||
constructForm('{% url "api-po-additional-line-list" %}', {
|
||||
constructForm('{% url "api-po-extra-line-list" %}', {
|
||||
method: 'POST',
|
||||
fields: fields,
|
||||
data: data,
|
||||
title: '{% trans "Duplicate Line Item" %}',
|
||||
title: '{% trans "Duplicate Line" %}',
|
||||
onSuccess: function(response) {
|
||||
$(table).bootstrapTable('refresh');
|
||||
}
|
||||
@ -1576,30 +1576,30 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
|
||||
});
|
||||
});
|
||||
|
||||
// Callback for editing line items
|
||||
// Callback for editing lines
|
||||
$(table).find('.button-edit').click(function() {
|
||||
var pk = $(this).attr('pk');
|
||||
|
||||
constructForm(`/api/order/po-additional-line/${pk}/`, {
|
||||
constructForm(`/api/order/po-extra-line/${pk}/`, {
|
||||
fields: {
|
||||
quantity: {},
|
||||
reference: {},
|
||||
sale_price: {},
|
||||
sale_price_currency: {},
|
||||
price: {},
|
||||
price_currency: {},
|
||||
notes: {},
|
||||
},
|
||||
title: '{% trans "Edit Line Item" %}',
|
||||
title: '{% trans "Edit Line" %}',
|
||||
onSuccess: reloadTable,
|
||||
});
|
||||
});
|
||||
|
||||
// Callback for deleting line items
|
||||
// Callback for deleting lines
|
||||
$(table).find('.button-delete').click(function() {
|
||||
var pk = $(this).attr('pk');
|
||||
|
||||
constructForm(`/api/order/po-additional-line/${pk}/`, {
|
||||
constructForm(`/api/order/po-extra-line/${pk}/`, {
|
||||
method: 'DELETE',
|
||||
title: '{% trans "Delete Line Item" %}',
|
||||
title: '{% trans "Delete Line" %}',
|
||||
onSuccess: reloadTable,
|
||||
});
|
||||
});
|
||||
@ -1607,10 +1607,10 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
|
||||
|
||||
$(table).inventreeTable({
|
||||
onPostBody: setupCallbacks,
|
||||
name: 'purchaseorderadditionallineitems',
|
||||
name: 'purchaseorderextraline',
|
||||
sidePagination: 'client',
|
||||
formatNoMatches: function() {
|
||||
return '{% trans "No matching line items" %}';
|
||||
return '{% trans "No matching line" %}';
|
||||
},
|
||||
queryParams: filters,
|
||||
original: options.params,
|
||||
@ -3039,14 +3039,14 @@ function loadSalesOrderLineItemTable(table, options={}) {
|
||||
|
||||
|
||||
/**
|
||||
* Load a table displaying line items for a particular SalesOrder
|
||||
* Load a table displaying lines for a particular SalesOrder
|
||||
*
|
||||
* @param {String} table : HTML ID tag e.g. '#table'
|
||||
* @param {Object} options : object which contains:
|
||||
* - order {integer} : pk of the SalesOrder
|
||||
* - status: {integer} : status code for the order
|
||||
*/
|
||||
function loadSalesOrderAdditionalLineItemTable(table, options={}) {
|
||||
function loadSalesOrderExtraLineTable(table, options={}) {
|
||||
|
||||
options.table = table;
|
||||
|
||||
@ -3066,17 +3066,17 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
|
||||
options.params.part_detail = true;
|
||||
options.params.allocations = true;
|
||||
|
||||
var filters = loadTableFilters('salesorderadditionallineitem');
|
||||
var filters = loadTableFilters('salesorderextraline');
|
||||
|
||||
for (var key in options.params) {
|
||||
filters[key] = options.params[key];
|
||||
}
|
||||
|
||||
options.url = options.url || '{% url "api-so-additional-line-list" %}';
|
||||
options.url = options.url || '{% url "api-so-extra-line-list" %}';
|
||||
|
||||
var filter_target = options.filter_target || '#filter-list-sales-order-additional-lines';
|
||||
var filter_target = options.filter_target || '#filter-list-sales-order-extra-lines';
|
||||
|
||||
setupFilterList('salesorderadditionallineitem', $(table), filter_target);
|
||||
setupFilterList('salesorderextraline', $(table), filter_target);
|
||||
|
||||
// Is the order pending?
|
||||
var pending = options.status == {{ SalesOrderStatus.PENDING }};
|
||||
@ -3104,18 +3104,18 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'sale_price',
|
||||
field: 'price',
|
||||
title: '{% trans "Unit Price" %}',
|
||||
formatter: function(value, row) {
|
||||
var formatter = new Intl.NumberFormat(
|
||||
'en-US',
|
||||
{
|
||||
style: 'currency',
|
||||
currency: row.sale_price_currency
|
||||
currency: row.price_currency
|
||||
}
|
||||
);
|
||||
|
||||
return formatter.format(row.sale_price);
|
||||
return formatter.format(row.price);
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -3127,20 +3127,20 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
|
||||
'en-US',
|
||||
{
|
||||
style: 'currency',
|
||||
currency: row.sale_price_currency
|
||||
currency: row.price_currency
|
||||
}
|
||||
);
|
||||
|
||||
return formatter.format(row.sale_price * row.quantity);
|
||||
return formatter.format(row.price * row.quantity);
|
||||
},
|
||||
footerFormatter: function(data) {
|
||||
var total = data.map(function(row) {
|
||||
return +row['sale_price'] * row['quantity'];
|
||||
return +row['price'] * row['quantity'];
|
||||
}).reduce(function(sum, i) {
|
||||
return sum + i;
|
||||
}, 0);
|
||||
|
||||
var currency = (data.slice(-1)[0] && data.slice(-1)[0].sale_price_currency) || 'USD';
|
||||
var currency = (data.slice(-1)[0] && data.slice(-1)[0].price_currency) || 'USD';
|
||||
|
||||
var formatter = new Intl.NumberFormat(
|
||||
'en-US',
|
||||
@ -3170,12 +3170,12 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
|
||||
|
||||
var pk = row.pk;
|
||||
|
||||
html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line item" %}');
|
||||
html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line item" %}');
|
||||
html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line" %}');
|
||||
html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line" %}');
|
||||
|
||||
var title = '{% trans "Delete line item" %}';
|
||||
var title = '{% trans "Delete line" %}';
|
||||
|
||||
// Prevent deletion of the line item if items have been allocated or shipped!
|
||||
// Prevent deletion of the lines if items have been allocated or shipped!
|
||||
html += makeIconButton('fa-trash-alt icon-red', 'button-delete', pk, title, );
|
||||
|
||||
html += `</div>`;
|
||||
@ -3193,20 +3193,20 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
|
||||
// Configure callback functions once the table is loaded
|
||||
function setupCallbacks() {
|
||||
|
||||
// Callback for duplicating line items
|
||||
// Callback for duplicating lines
|
||||
$(table).find('.button-duplicate').click(function() {
|
||||
var pk = $(this).attr('pk');
|
||||
|
||||
inventreeGet(`/api/order/so-additional-line/${pk}/`, {}, {
|
||||
inventreeGet(`/api/order/so-extra-line/${pk}/`, {}, {
|
||||
success: function(data) {
|
||||
|
||||
var fields = additionalLineItemFields();
|
||||
var fields = extraLineFields();
|
||||
|
||||
constructForm('{% url "api-so-additional-line-list" %}', {
|
||||
constructForm('{% url "api-so-extra-line-list" %}', {
|
||||
method: 'POST',
|
||||
fields: fields,
|
||||
data: data,
|
||||
title: '{% trans "Duplicate Line Item" %}',
|
||||
title: '{% trans "Duplicate Line" %}',
|
||||
onSuccess: function(response) {
|
||||
$(table).bootstrapTable('refresh');
|
||||
}
|
||||
@ -3215,30 +3215,30 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
|
||||
});
|
||||
});
|
||||
|
||||
// Callback for editing line items
|
||||
// Callback for editing lines
|
||||
$(table).find('.button-edit').click(function() {
|
||||
var pk = $(this).attr('pk');
|
||||
|
||||
constructForm(`/api/order/so-additional-line/${pk}/`, {
|
||||
constructForm(`/api/order/so-extra-line/${pk}/`, {
|
||||
fields: {
|
||||
quantity: {},
|
||||
reference: {},
|
||||
sale_price: {},
|
||||
sale_price_currency: {},
|
||||
price: {},
|
||||
price_currency: {},
|
||||
notes: {},
|
||||
},
|
||||
title: '{% trans "Edit Line Item" %}',
|
||||
title: '{% trans "Edit Line" %}',
|
||||
onSuccess: reloadTable,
|
||||
});
|
||||
});
|
||||
|
||||
// Callback for deleting line items
|
||||
// Callback for deleting lines
|
||||
$(table).find('.button-delete').click(function() {
|
||||
var pk = $(this).attr('pk');
|
||||
|
||||
constructForm(`/api/order/so-additional-line/${pk}/`, {
|
||||
constructForm(`/api/order/so-extra-line/${pk}/`, {
|
||||
method: 'DELETE',
|
||||
title: '{% trans "Delete Line Item" %}',
|
||||
title: '{% trans "Delete Line" %}',
|
||||
onSuccess: reloadTable,
|
||||
});
|
||||
});
|
||||
@ -3246,10 +3246,10 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
|
||||
|
||||
$(table).inventreeTable({
|
||||
onPostBody: setupCallbacks,
|
||||
name: 'salesorderadditionallineitems',
|
||||
name: 'salesorderextraline',
|
||||
sidePagination: 'client',
|
||||
formatNoMatches: function() {
|
||||
return '{% trans "No matching line items" %}';
|
||||
return '{% trans "No matching lines" %}';
|
||||
},
|
||||
queryParams: filters,
|
||||
original: options.params,
|
||||
|
@ -132,7 +132,7 @@ class RuleSet(models.Model):
|
||||
'order_purchaseorder',
|
||||
'order_purchaseorderattachment',
|
||||
'order_purchaseorderlineitem',
|
||||
'order_purchaseorderadditionallineitem',
|
||||
'order_purchaseorderextraline',
|
||||
'company_supplierpart',
|
||||
'company_manufacturerpart',
|
||||
'company_manufacturerpartparameter',
|
||||
@ -143,7 +143,7 @@ class RuleSet(models.Model):
|
||||
'order_salesorderallocation',
|
||||
'order_salesorderattachment',
|
||||
'order_salesorderlineitem',
|
||||
'order_salesorderadditionallineitem',
|
||||
'order_salesorderextraline',
|
||||
'order_salesordershipment',
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user