rename AdditionalLineItems to ExtraLine

This commit is contained in:
Matthias 2022-03-27 01:11:25 +01:00
parent ce68ee3781
commit bff2fb81f3
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
9 changed files with 188 additions and 188 deletions

View File

@ -8,13 +8,13 @@ from import_export.admin import ImportExportModelAdmin
from import_export.resources import ModelResource from import_export.resources import ModelResource
from import_export.fields import Field from import_export.fields import Field
from .models import PurchaseOrder, PurchaseOrderLineItem, PurchaseOrderAdditionalLineItem from .models import PurchaseOrder, PurchaseOrderLineItem, PurchaseOrderExtraLine
from .models import SalesOrder, SalesOrderLineItem, SalesOrderAdditionalLineItem from .models import SalesOrder, SalesOrderLineItem, SalesOrderExtraLine
from .models import SalesOrderShipment, SalesOrderAllocation from .models import SalesOrderShipment, SalesOrderAllocation
# region general classes # region general classes
class GeneralAdditionalLineItemAdmin: class GeneralExtraLineAdmin:
list_display = ( list_display = (
'order', 'order',
'quantity', 'quantity',
@ -30,7 +30,7 @@ class GeneralAdditionalLineItemAdmin:
autocomplete_fields = ('order', ) autocomplete_fields = ('order', )
class GeneralAdditionalLineMeta: class GeneralExtraLineMeta:
skip_unchanged = True skip_unchanged = True
report_skipped = False report_skipped = False
clean_model_instances = True clean_model_instances = True
@ -110,11 +110,11 @@ class POLineItemResource(ModelResource):
clean_model_instances = True clean_model_instances = True
class POAdditionalLineItemResource(ModelResource): class POExtraLineResource(ModelResource):
""" Class for managing import / export of POAdditionalLineItem data """ """ Class for managing import / export of POExtraLine data """
class Meta(GeneralAdditionalLineMeta): class Meta(GeneralExtraLineMeta):
model = PurchaseOrderAdditionalLineItem model = PurchaseOrderExtraLine
class SOLineItemResource(ModelResource): class SOLineItemResource(ModelResource):
@ -148,11 +148,11 @@ class SOLineItemResource(ModelResource):
clean_model_instances = True clean_model_instances = True
class SOAdditionalLineItemResource(ModelResource): class SOExtraLineResource(ModelResource):
""" Class for managing import / export of SOAdditionalLineItem data """ """ Class for managing import / export of SOExtraLine data """
class Meta(GeneralAdditionalLineMeta): class Meta(GeneralExtraLineMeta):
model = SalesOrderAdditionalLineItem model = SalesOrderExtraLine
class PurchaseOrderLineItemAdmin(ImportExportModelAdmin): class PurchaseOrderLineItemAdmin(ImportExportModelAdmin):
@ -171,9 +171,9 @@ class PurchaseOrderLineItemAdmin(ImportExportModelAdmin):
autocomplete_fields = ('order', 'part', 'destination',) autocomplete_fields = ('order', 'part', 'destination',)
class PurchaseOrderAdditionalLineItemAdmin(GeneralAdditionalLineItemAdmin, ImportExportModelAdmin): class PurchaseOrderExtraLineAdmin(GeneralExtraLineAdmin, ImportExportModelAdmin):
resource_class = POAdditionalLineItemResource resource_class = POExtraLineResource
class SalesOrderLineItemAdmin(ImportExportModelAdmin): class SalesOrderLineItemAdmin(ImportExportModelAdmin):
@ -197,9 +197,9 @@ class SalesOrderLineItemAdmin(ImportExportModelAdmin):
autocomplete_fields = ('order', 'part',) autocomplete_fields = ('order', 'part',)
class SalesOrderAdditionalLineItemAdmin(GeneralAdditionalLineItemAdmin, ImportExportModelAdmin): class SalesOrderExtraLineAdmin(GeneralExtraLineAdmin, ImportExportModelAdmin):
resource_class = SOAdditionalLineItemResource resource_class = SOExtraLineResource
class SalesOrderShipmentAdmin(ImportExportModelAdmin): class SalesOrderShipmentAdmin(ImportExportModelAdmin):
@ -232,11 +232,11 @@ class SalesOrderAllocationAdmin(ImportExportModelAdmin):
admin.site.register(PurchaseOrder, PurchaseOrderAdmin) admin.site.register(PurchaseOrder, PurchaseOrderAdmin)
admin.site.register(PurchaseOrderLineItem, PurchaseOrderLineItemAdmin) admin.site.register(PurchaseOrderLineItem, PurchaseOrderLineItemAdmin)
admin.site.register(PurchaseOrderAdditionalLineItem, PurchaseOrderAdditionalLineItemAdmin) admin.site.register(PurchaseOrderExtraLine, PurchaseOrderExtraLineAdmin)
admin.site.register(SalesOrder, SalesOrderAdmin) admin.site.register(SalesOrder, SalesOrderAdmin)
admin.site.register(SalesOrderLineItem, SalesOrderLineItemAdmin) admin.site.register(SalesOrderLineItem, SalesOrderLineItemAdmin)
admin.site.register(SalesOrderAdditionalLineItem, SalesOrderAdditionalLineItemAdmin) admin.site.register(SalesOrderExtraLine, SalesOrderExtraLineAdmin)
admin.site.register(SalesOrderShipment, SalesOrderShipmentAdmin) admin.site.register(SalesOrderShipment, SalesOrderShipmentAdmin)
admin.site.register(SalesOrderAllocation, SalesOrderAllocationAdmin) admin.site.register(SalesOrderAllocation, SalesOrderAllocationAdmin)

View File

@ -27,9 +27,9 @@ from part.models import Part
from users.models import Owner 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): def get_serializer(self, *args, **kwargs):
@ -501,20 +501,20 @@ class POLineItemDetail(generics.RetrieveUpdateDestroyAPIView):
return queryset 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() queryset = models.PurchaseOrderExtraLine.objects.all()
serializer_class = serializers.POAdditionalLineItemSerializer serializer_class = serializers.POExtraLineSerializer
class POAdditionalLineItemDetail(generics.RetrieveUpdateDestroyAPIView): class POExtraLineDetail(generics.RetrieveUpdateDestroyAPIView):
""" API endpoint for detail view of a PurchaseOrderAdditionalLineItem object """ """ API endpoint for detail view of a PurchaseOrderExtraLine object """
queryset = models.PurchaseOrderAdditionalLineItem.objects.all() queryset = models.PurchaseOrderExtraLine.objects.all()
serializer_class = serializers.POAdditionalLineItemSerializer serializer_class = serializers.POExtraLineSerializer
class SOAttachmentList(generics.ListCreateAPIView, AttachmentMixin): 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() queryset = models.SalesOrderExtraLine.objects.all()
serializer_class = serializers.SOAdditionalLineItemSerializer serializer_class = serializers.SOExtraLineSerializer
class SOAdditionalLineItemDetail(generics.RetrieveUpdateDestroyAPIView): class SOExtraLineDetail(generics.RetrieveUpdateDestroyAPIView):
""" API endpoint for detail view of a SalesOrderAdditionalLineItem object """ """ API endpoint for detail view of a SalesOrderExtraLine object """
queryset = models.SalesOrderAdditionalLineItem.objects.all() queryset = models.SalesOrderExtraLine.objects.all()
serializer_class = serializers.SOAdditionalLineItemSerializer serializer_class = serializers.SOExtraLineSerializer
class SOLineItemDetail(generics.RetrieveUpdateDestroyAPIView): class SOLineItemDetail(generics.RetrieveUpdateDestroyAPIView):
@ -1120,10 +1120,10 @@ order_api_urls = [
url(r'^.*$', POLineItemList.as_view(), name='api-po-line-list'), url(r'^.*$', POLineItemList.as_view(), name='api-po-line-list'),
])), ])),
# API endpoints for purchase order additional line items # API endpoints for purchase order extra line
url(r'^po-additional-line/', include([ url(r'^po-extra-line/', include([
url(r'^(?P<pk>\d+)/$', POAdditionalLineItemDetail.as_view(), name='api-po-additional-line-detail'), url(r'^(?P<pk>\d+)/$', POExtraLineDetail.as_view(), name='api-po-extra-line-detail'),
url(r'^$', POAdditionalLineItemList.as_view(), name='api-po-additional-line-list'), url(r'^$', POExtraLineList.as_view(), name='api-po-extra-line-list'),
])), ])),
# API endpoints for sales ordesr # API endpoints for sales ordesr
@ -1159,10 +1159,10 @@ order_api_urls = [
url(r'^$', SOLineItemList.as_view(), name='api-so-line-list'), url(r'^$', SOLineItemList.as_view(), name='api-so-line-list'),
])), ])),
# API endpoints for sales order additional line items # API endpoints for sales order extra line
url(r'^so-additional-line/', include([ url(r'^so-extra-line/', include([
url(r'^(?P<pk>\d+)/$', SOAdditionalLineItemDetail.as_view(), name='api-so-additional-line-detail'), url(r'^(?P<pk>\d+)/$', SOExtraLineDetail.as_view(), name='api-so-extra-line-detail'),
url(r'^$', SOAdditionalLineItemList.as_view(), name='api-so-additional-line-list'), url(r'^$', SOExtraLineList.as_view(), name='api-so-extra-line-list'),
])), ])),
# API endpoints for sales order allocations # API endpoints for sales order allocations

View File

@ -163,8 +163,8 @@ class Order(ReferenceIndexingMixin):
# order items # 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)]) 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 # extra lines
total += sum([a.quantity * convert_money(a.sale_price, target_currency) for a in self.additional_lines.all() if a.sale_price]) total += sum([a.quantity * convert_money(a.price, target_currency) for a in self.extra_lines.all() if a.price])
# set decimal-places # set decimal-places
total.decimal_places = 4 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: Attributes:
sale_price: The unit sale price for this OrderLineItem price: The unit sale price for this OrderLineItem
""" """
class Meta: class Meta:
@ -887,18 +887,18 @@ class OrderAdditionalLineItem(OrderLineItem):
unique_together = [ unique_together = [
] ]
sale_price = InvenTreeModelMoneyField( price = InvenTreeModelMoneyField(
max_digits=19, max_digits=19,
decimal_places=4, decimal_places=4,
null=True, blank=True, null=True, blank=True,
verbose_name=_('Sale Price'), verbose_name=_('Price'),
help_text=_('Unit sale price'), help_text=_('Unit price'),
) )
def sale_price_converted(self): def price_converted(self):
return convert_money(self.sale_price, currency_code_default()) return convert_money(self.price, currency_code_default())
def sale_price_converted_currency(self): def price_converted_currency(self):
return currency_code_default() return currency_code_default()
@ -1011,19 +1011,19 @@ class PurchaseOrderLineItem(OrderLineItem):
return max(r, 0) 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: Attributes:
order: Link to the PurchaseOrder that this line item belongs to order: Link to the PurchaseOrder that this line belongs to
title: title of line item title: title of line
sale_price: The unit sale price for this OrderLineItem price: The unit price for this OrderLine
""" """
@staticmethod @staticmethod
def get_api_url(): 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): class SalesOrderLineItem(OrderLineItem):
@ -1229,19 +1229,19 @@ class SalesOrderShipment(models.Model):
trigger_event('salesordershipment.completed', id=self.pk) 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: Attributes:
order: Link to the SalesOrder that this line item belongs to order: Link to the SalesOrder that this line belongs to
title: title of line item title: title of line
sale_price: The unit sale price for this OrderLineItem price: The unit price for this OrderLine
""" """
@staticmethod @staticmethod
def get_api_url(): 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): class SalesOrderAllocation(models.Model):

View File

@ -53,8 +53,8 @@ class AbstractOrderSerializer(serializers.Serializer):
total_price_string = serializers.CharField(source='get_total_price', read_only=True) total_price_string = serializers.CharField(source='get_total_price', read_only=True)
class AbstractAdditionalLineItemSerializer(serializers.Serializer): class AbstractExtraLineSerializer(serializers.Serializer):
""" Abstract Serializer for a AdditionalLineItem object """ """ Abstract Serializer for a ExtraLine object """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
order_detail = kwargs.pop('order_detail', False) order_detail = kwargs.pop('order_detail', False)
@ -66,21 +66,21 @@ class AbstractAdditionalLineItemSerializer(serializers.Serializer):
quantity = serializers.FloatField() quantity = serializers.FloatField()
sale_price = InvenTreeMoneySerializer( price = InvenTreeMoneySerializer(
allow_null=True 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(), 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 = [ fields = [
@ -90,9 +90,9 @@ class AbstractAdditionalLineItemMeta:
'notes', 'notes',
'order', 'order',
'order_detail', 'order_detail',
'sale_price', 'price',
'sale_price_currency', 'price_currency',
'sale_price_string', 'price_string',
] ]
@ -272,13 +272,13 @@ class POLineItemSerializer(InvenTreeModelSerializer):
] ]
class POAdditionalLineItemSerializer(AbstractAdditionalLineItemSerializer, InvenTreeModelSerializer): class POExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer):
""" Serializer for a PurchaseOrderAdditionalLineItem object """ """ Serializer for a PurchaseOrderExtraLine object """
order_detail = POSerializer(source='order', many=False, read_only=True) order_detail = POSerializer(source='order', many=False, read_only=True)
class Meta(AbstractAdditionalLineItemMeta): class Meta(AbstractExtraLineMeta):
model = order.models.PurchaseOrderAdditionalLineItem model = order.models.PurchaseOrderExtraLine
class POLineItemReceiveSerializer(serializers.Serializer): class POLineItemReceiveSerializer(serializers.Serializer):
@ -1168,13 +1168,13 @@ class SOShipmentAllocationSerializer(serializers.Serializer):
) )
class SOAdditionalLineItemSerializer(AbstractAdditionalLineItemSerializer, InvenTreeModelSerializer): class SOExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer):
""" Serializer for a SalesOrderAdditionalLineItem object """ """ Serializer for a SalesOrderExtraLine object """
order_detail = SalesOrderSerializer(source='order', many=False, read_only=True) order_detail = SalesOrderSerializer(source='order', many=False, read_only=True)
class Meta(AbstractAdditionalLineItemMeta): class Meta(AbstractExtraLineMeta):
model = order.models.SalesOrderAdditionalLineItem model = order.models.SalesOrderExtraLine
class SOAttachmentSerializer(InvenTreeAttachmentSerializer): class SOAttachmentSerializer(InvenTreeAttachmentSerializer):

View File

@ -46,24 +46,24 @@
<div class='panel-heading'> <div class='panel-heading'>
<div class='d-flex flex-wrap'> <div class='d-flex flex-wrap'>
<h4>{% trans "Additional Order Items" %}</h4> <h4>{% trans "Extra Lines" %}</h4>
{% include "spacer.html" %} {% include "spacer.html" %}
<div class='btn-group' role='group'> <div class='btn-group' role='group'>
{% if roles.purchase_order.change and order.status == PurchaseOrderStatus.PENDING %} {% if roles.purchase_order.change and order.status == PurchaseOrderStatus.PENDING %}
<button type='button' class='btn btn-success' id='new-po-additional-line'> <button type='button' class='btn btn-success' id='new-po-extra-line'>
<span class='fas fa-plus-circle'></span> {% trans "Add Additional Order Items" %} <span class='fas fa-plus-circle'></span> {% trans "Add Extra Line" %}
</button> </button>
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div> </div>
<div class='panel-content'> <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'> <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>
</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> </table>
</div> </div>
</div> </div>
@ -230,24 +230,24 @@ loadPurchaseOrderLineItemTable('#po-line-table', {
{% endif %} {% endif %}
}); });
$("#new-po-additional-line").click(function() { $("#new-po-extra-line").click(function() {
var fields = additionalLineItemFields({ var fields = extraLineFields({
order: {{ order.pk }}, order: {{ order.pk }},
}); });
constructForm('{% url "api-po-additional-line-list" %}', { constructForm('{% url "api-po-extra-line-list" %}', {
fields: fields, fields: fields,
method: 'POST', method: 'POST',
title: '{% trans "Add Order Line" %}', title: '{% trans "Add Order Line" %}',
onSuccess: function() { onSuccess: function() {
$("#po-additional-lines-table").bootstrapTable("refresh"); $("#po-extra-lines-table").bootstrapTable("refresh");
}, },
}); });
}); });
loadPurchaseOrderAdditionalLineItemTable( loadPurchaseOrderExtraLineTable(
'#po-additional-lines-table', '#po-extra-lines-table',
{ {
order: {{ order.pk }}, order: {{ order.pk }},
status: {{ order.status }}, status: {{ order.status }},

View File

@ -38,24 +38,24 @@
<div class='panel-heading'> <div class='panel-heading'>
<div class='d-flex flex-wrap'> <div class='d-flex flex-wrap'>
<h4>{% trans "Additional Order Items" %}</h4> <h4>{% trans "Extra Lines" %}</h4>
{% include "spacer.html" %} {% include "spacer.html" %}
<div class='btn-group' role='group'> <div class='btn-group' role='group'>
{% if roles.sales_order.change and order.is_pending %} {% if roles.sales_order.change and order.is_pending %}
<button type='button' class='btn btn-success' id='new-so-additional-line'> <button type='button' class='btn btn-success' id='new-so-extra-line'>
<span class='fas fa-plus-circle'></span> {% trans "Add Additional Order Items" %} <span class='fas fa-plus-circle'></span> {% trans "Add Extra Line" %}
</button> </button>
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div> </div>
<div class='panel-content'> <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'> <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>
</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> </table>
</div> </div>
</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 }}, order: {{ order.pk }},
}); });
constructForm('{% url "api-so-additional-line-list" %}', { constructForm('{% url "api-so-extra-line-list" %}', {
fields: fields, fields: fields,
method: 'POST', method: 'POST',
title: '{% trans "Add Order Line" %}', title: '{% trans "Add Extra Line" %}',
onSuccess: function() { onSuccess: function() {
$("#so-additional-lines-table").bootstrapTable("refresh"); $("#so-extra-lines-table").bootstrapTable("refresh");
}, },
}); });
}); });
loadSalesOrderAdditionalLineItemTable( loadSalesOrderExtraLineTable(
'#so-additional-lines-table', '#so-extra-lines-table',
{ {
order: {{ order.pk }}, order: {{ order.pk }},
status: {{ order.status }}, status: {{ order.status }},

View File

@ -466,7 +466,7 @@ class PurchaseOrderReport(ReportTemplateBase):
return { return {
'description': order.description, 'description': order.description,
'lines': order.lines, 'lines': order.lines,
'additional_lines': order.additional_lines, 'extra_lines': order.extra_lines,
'order': order, 'order': order,
'reference': order.reference, 'reference': order.reference,
'supplier': order.supplier, 'supplier': order.supplier,
@ -506,7 +506,7 @@ class SalesOrderReport(ReportTemplateBase):
'customer': order.customer, 'customer': order.customer,
'description': order.description, 'description': order.description,
'lines': order.lines, 'lines': order.lines,
'additional_lines': order.additional_lines, 'extra_lines': order.extra_lines,
'order': order, 'order': order,
'prefix': common.models.InvenTreeSetting.get_setting('SALESORDER_REFERENCE_PREFIX'), 'prefix': common.models.InvenTreeSetting.get_setting('SALESORDER_REFERENCE_PREFIX'),
'reference': order.reference, 'reference': order.reference,

View File

@ -26,11 +26,11 @@
editPurchaseOrderLineItem, editPurchaseOrderLineItem,
exportOrder, exportOrder,
loadPurchaseOrderLineItemTable, loadPurchaseOrderLineItemTable,
loadPurchaseOrderAdditionalLineItemTable loadPurchaseOrderExtraLineTable
loadPurchaseOrderTable, loadPurchaseOrderTable,
loadSalesOrderAllocationTable, loadSalesOrderAllocationTable,
loadSalesOrderLineItemTable, loadSalesOrderLineItemTable,
loadSalesOrderAdditionalLineItemTable loadSalesOrderExtraLineTable
loadSalesOrderShipmentTable, loadSalesOrderShipmentTable,
loadSalesOrderTable, loadSalesOrderTable,
newPurchaseOrderFromOrderWizard, newPurchaseOrderFromOrderWizard,
@ -38,7 +38,7 @@
removeOrderRowFromOrderWizard, removeOrderRowFromOrderWizard,
removePurchaseOrderLineItem, removePurchaseOrderLineItem,
loadOrderTotal, loadOrderTotal,
additionalLineItemFields, ExtraLineFields,
*/ */
@ -309,8 +309,8 @@ function soLineItemFields(options={}) {
} }
/* Construct a set of fields for a OrderAdditionalLineItem form */ /* Construct a set of fields for a OrderExtraLine form */
function additionalLineItemFields(options={}) { function extraLineFields(options={}) {
var fields = { var fields = {
order: { order: {
@ -318,8 +318,8 @@ function additionalLineItemFields(options={}) {
}, },
quantity: {}, quantity: {},
reference: {}, reference: {},
sale_price: {}, price: {},
sale_price_currency: {}, price_currency: {},
notes: {}, 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 {String} table : HTML ID tag e.g. '#table'
* @param {Object} options : object which contains: * @param {Object} options : object which contains:
* - order {integer} : pk of the PurchaseOrder * - order {integer} : pk of the PurchaseOrder
* - status: {integer} : status code for the order * - status: {integer} : status code for the order
*/ */
function loadPurchaseOrderAdditionalLineItemTable(table, options={}) { function loadPurchaseOrderExtraLineTable(table, options={}) {
options.table = table; options.table = table;
@ -1427,17 +1427,17 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
options.params.part_detail = true; options.params.part_detail = true;
options.params.allocations = true; options.params.allocations = true;
var filters = loadTableFilters('purchaseorderadditionallineitem'); var filters = loadTableFilters('purchaseorderextraline');
for (var key in options.params) { for (var key in options.params) {
filters[key] = options.params[key]; 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? // Is the order pending?
var pending = options.status == {{ SalesOrderStatus.PENDING }}; var pending = options.status == {{ SalesOrderStatus.PENDING }};
@ -1465,18 +1465,18 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
}, },
{ {
sortable: true, sortable: true,
field: 'sale_price', field: 'price',
title: '{% trans "Unit Price" %}', title: '{% trans "Unit Price" %}',
formatter: function(value, row) { formatter: function(value, row) {
var formatter = new Intl.NumberFormat( var formatter = new Intl.NumberFormat(
'en-US', 'en-US',
{ {
style: 'currency', 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', 'en-US',
{ {
style: 'currency', 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) { footerFormatter: function(data) {
var total = data.map(function(row) { var total = data.map(function(row) {
return +row['sale_price'] * row['quantity']; return +row['price'] * row['quantity'];
}).reduce(function(sum, i) { }).reduce(function(sum, i) {
return sum + i; return sum + i;
}, 0); }, 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( var formatter = new Intl.NumberFormat(
'en-US', 'en-US',
@ -1531,12 +1531,12 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
var pk = row.pk; var pk = row.pk;
html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line item" %}'); html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line" %}');
html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line item" %}'); 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 += makeIconButton('fa-trash-alt icon-red', 'button-delete', pk, title, );
html += `</div>`; html += `</div>`;
@ -1554,20 +1554,20 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
// Configure callback functions once the table is loaded // Configure callback functions once the table is loaded
function setupCallbacks() { function setupCallbacks() {
// Callback for duplicating line items // Callback for duplicating lines
$(table).find('.button-duplicate').click(function() { $(table).find('.button-duplicate').click(function() {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
inventreeGet(`/api/order/po-additional-line/${pk}/`, {}, { inventreeGet(`/api/order/po-extra-line/${pk}/`, {}, {
success: function(data) { 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', method: 'POST',
fields: fields, fields: fields,
data: data, data: data,
title: '{% trans "Duplicate Line Item" %}', title: '{% trans "Duplicate Line" %}',
onSuccess: function(response) { onSuccess: function(response) {
$(table).bootstrapTable('refresh'); $(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() { $(table).find('.button-edit').click(function() {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
constructForm(`/api/order/po-additional-line/${pk}/`, { constructForm(`/api/order/po-extra-line/${pk}/`, {
fields: { fields: {
quantity: {}, quantity: {},
reference: {}, reference: {},
sale_price: {}, price: {},
sale_price_currency: {}, price_currency: {},
notes: {}, notes: {},
}, },
title: '{% trans "Edit Line Item" %}', title: '{% trans "Edit Line" %}',
onSuccess: reloadTable, onSuccess: reloadTable,
}); });
}); });
// Callback for deleting line items // Callback for deleting lines
$(table).find('.button-delete').click(function() { $(table).find('.button-delete').click(function() {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
constructForm(`/api/order/po-additional-line/${pk}/`, { constructForm(`/api/order/po-extra-line/${pk}/`, {
method: 'DELETE', method: 'DELETE',
title: '{% trans "Delete Line Item" %}', title: '{% trans "Delete Line" %}',
onSuccess: reloadTable, onSuccess: reloadTable,
}); });
}); });
@ -1607,10 +1607,10 @@ function loadPurchaseOrderAdditionalLineItemTable(table, options={}) {
$(table).inventreeTable({ $(table).inventreeTable({
onPostBody: setupCallbacks, onPostBody: setupCallbacks,
name: 'purchaseorderadditionallineitems', name: 'purchaseorderextraline',
sidePagination: 'client', sidePagination: 'client',
formatNoMatches: function() { formatNoMatches: function() {
return '{% trans "No matching line items" %}'; return '{% trans "No matching line" %}';
}, },
queryParams: filters, queryParams: filters,
original: options.params, 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 {String} table : HTML ID tag e.g. '#table'
* @param {Object} options : object which contains: * @param {Object} options : object which contains:
* - order {integer} : pk of the SalesOrder * - order {integer} : pk of the SalesOrder
* - status: {integer} : status code for the order * - status: {integer} : status code for the order
*/ */
function loadSalesOrderAdditionalLineItemTable(table, options={}) { function loadSalesOrderExtraLineTable(table, options={}) {
options.table = table; options.table = table;
@ -3066,17 +3066,17 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
options.params.part_detail = true; options.params.part_detail = true;
options.params.allocations = true; options.params.allocations = true;
var filters = loadTableFilters('salesorderadditionallineitem'); var filters = loadTableFilters('salesorderextraline');
for (var key in options.params) { for (var key in options.params) {
filters[key] = options.params[key]; 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? // Is the order pending?
var pending = options.status == {{ SalesOrderStatus.PENDING }}; var pending = options.status == {{ SalesOrderStatus.PENDING }};
@ -3104,18 +3104,18 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
}, },
{ {
sortable: true, sortable: true,
field: 'sale_price', field: 'price',
title: '{% trans "Unit Price" %}', title: '{% trans "Unit Price" %}',
formatter: function(value, row) { formatter: function(value, row) {
var formatter = new Intl.NumberFormat( var formatter = new Intl.NumberFormat(
'en-US', 'en-US',
{ {
style: 'currency', 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', 'en-US',
{ {
style: 'currency', 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) { footerFormatter: function(data) {
var total = data.map(function(row) { var total = data.map(function(row) {
return +row['sale_price'] * row['quantity']; return +row['price'] * row['quantity'];
}).reduce(function(sum, i) { }).reduce(function(sum, i) {
return sum + i; return sum + i;
}, 0); }, 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( var formatter = new Intl.NumberFormat(
'en-US', 'en-US',
@ -3170,12 +3170,12 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
var pk = row.pk; var pk = row.pk;
html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line item" %}'); html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line" %}');
html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line item" %}'); 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 += makeIconButton('fa-trash-alt icon-red', 'button-delete', pk, title, );
html += `</div>`; html += `</div>`;
@ -3193,20 +3193,20 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
// Configure callback functions once the table is loaded // Configure callback functions once the table is loaded
function setupCallbacks() { function setupCallbacks() {
// Callback for duplicating line items // Callback for duplicating lines
$(table).find('.button-duplicate').click(function() { $(table).find('.button-duplicate').click(function() {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
inventreeGet(`/api/order/so-additional-line/${pk}/`, {}, { inventreeGet(`/api/order/so-extra-line/${pk}/`, {}, {
success: function(data) { 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', method: 'POST',
fields: fields, fields: fields,
data: data, data: data,
title: '{% trans "Duplicate Line Item" %}', title: '{% trans "Duplicate Line" %}',
onSuccess: function(response) { onSuccess: function(response) {
$(table).bootstrapTable('refresh'); $(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() { $(table).find('.button-edit').click(function() {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
constructForm(`/api/order/so-additional-line/${pk}/`, { constructForm(`/api/order/so-extra-line/${pk}/`, {
fields: { fields: {
quantity: {}, quantity: {},
reference: {}, reference: {},
sale_price: {}, price: {},
sale_price_currency: {}, price_currency: {},
notes: {}, notes: {},
}, },
title: '{% trans "Edit Line Item" %}', title: '{% trans "Edit Line" %}',
onSuccess: reloadTable, onSuccess: reloadTable,
}); });
}); });
// Callback for deleting line items // Callback for deleting lines
$(table).find('.button-delete').click(function() { $(table).find('.button-delete').click(function() {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
constructForm(`/api/order/so-additional-line/${pk}/`, { constructForm(`/api/order/so-extra-line/${pk}/`, {
method: 'DELETE', method: 'DELETE',
title: '{% trans "Delete Line Item" %}', title: '{% trans "Delete Line" %}',
onSuccess: reloadTable, onSuccess: reloadTable,
}); });
}); });
@ -3246,10 +3246,10 @@ function loadSalesOrderAdditionalLineItemTable(table, options={}) {
$(table).inventreeTable({ $(table).inventreeTable({
onPostBody: setupCallbacks, onPostBody: setupCallbacks,
name: 'salesorderadditionallineitems', name: 'salesorderextraline',
sidePagination: 'client', sidePagination: 'client',
formatNoMatches: function() { formatNoMatches: function() {
return '{% trans "No matching line items" %}'; return '{% trans "No matching lines" %}';
}, },
queryParams: filters, queryParams: filters,
original: options.params, original: options.params,

View File

@ -132,7 +132,7 @@ class RuleSet(models.Model):
'order_purchaseorder', 'order_purchaseorder',
'order_purchaseorderattachment', 'order_purchaseorderattachment',
'order_purchaseorderlineitem', 'order_purchaseorderlineitem',
'order_purchaseorderadditionallineitem', 'order_purchaseorderextraline',
'company_supplierpart', 'company_supplierpart',
'company_manufacturerpart', 'company_manufacturerpart',
'company_manufacturerpartparameter', 'company_manufacturerpartparameter',
@ -143,7 +143,7 @@ class RuleSet(models.Model):
'order_salesorderallocation', 'order_salesorderallocation',
'order_salesorderattachment', 'order_salesorderattachment',
'order_salesorderlineitem', 'order_salesorderlineitem',
'order_salesorderadditionallineitem', 'order_salesorderextraline',
'order_salesordershipment', 'order_salesordershipment',
] ]
} }