diff --git a/InvenTree/order/templates/order/sales_order_detail.html b/InvenTree/order/templates/order/sales_order_detail.html index e611ebc9e1..33487398b1 100644 --- a/InvenTree/order/templates/order/sales_order_detail.html +++ b/InvenTree/order/templates/order/sales_order_detail.html @@ -296,7 +296,8 @@ $("#so-lines-table").inventreeTable({ if (part.assembly) { html += makeIconButton('fa-tools', 'button-build', row.part, '{% trans "Build stock" %}'); } - + + html += makeIconButton('fa-dollar-sign icon-green', 'button-price', pk, '{% trans "Calculate price" %}'); } html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line item" %}'); @@ -396,6 +397,20 @@ function setupCallbacks() { }, }); }); + + $(".button-price").click(function() { + var pk = $(this).attr('pk'); + + launchModalForm( + "{% url 'line-pricing' %}", + { + submit_text: '{% trans "Calculate price" %}', + data: { + line_item: pk, + }, + } + ); + }); } {% endblock %} \ No newline at end of file diff --git a/InvenTree/order/urls.py b/InvenTree/order/urls.py index 97903d81c1..746a482c4a 100644 --- a/InvenTree/order/urls.py +++ b/InvenTree/order/urls.py @@ -31,6 +31,7 @@ purchase_order_urls = [ url(r'^new/', views.PurchaseOrderCreate.as_view(), name='po-create'), url(r'^order-parts/', views.OrderParts.as_view(), name='order-parts'), + url(r'^pricing/', views.LineItemPricing.as_view(), name='line-pricing'), # Display detail view for a single purchase order url(r'^(?P\d+)/', include(purchase_order_detail_urls)), diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index 284a24fcf5..9b642feb83 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -29,6 +29,7 @@ from part.models import Part from common.models import InvenTreeSetting from . import forms as order_forms +from part.views import PartPricing from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView from InvenTree.helpers import DownloadFile, str2bool @@ -1559,3 +1560,17 @@ class SalesOrderAllocationDelete(AjaxDeleteView): ajax_form_title = _("Remove allocation") context_object_name = 'allocation' ajax_template_name = "order/so_allocation_delete.html" + + +class LineItemPricing(PartPricing): + """ View for inspecting part pricing information """ + + def get_part(self): + if 'line_item' in self.request.GET: + try: + part_id = self.request.GET.get('line_item') + return SalesOrderLineItem.objects.get(id=part_id).part + except Part.DoesNotExist: + return None + else: + return None