add in price modal in table

This commit is contained in:
Matthias 2021-05-05 20:53:53 +02:00
parent ee028ef925
commit dc4fb64987
3 changed files with 32 additions and 1 deletions

View File

@ -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 %}

View File

@ -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<pk>\d+)/', include(purchase_order_detail_urls)),

View File

@ -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