diff --git a/InvenTree/company/templates/company/supplier_part_create.html b/InvenTree/company/templates/company/supplier_part_create.html new file mode 100644 index 0000000000..21c23f9075 --- /dev/null +++ b/InvenTree/company/templates/company/supplier_part_create.html @@ -0,0 +1,17 @@ +{% extends "modal_form.html" %} + +{% load i18n %} + +{% block pre_form_content %} +{{ block.super }} + +{% if part %} +
+ {% include "hover_image.html" with image=part.image %} + {{ part.full_name}} +
+ {{ part.description }} +
+{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/company/views.py b/InvenTree/company/views.py index 2720f4ccac..e863fa1d72 100644 --- a/InvenTree/company/views.py +++ b/InvenTree/company/views.py @@ -291,7 +291,7 @@ class SupplierPartCreate(AjaxCreateView): model = SupplierPart form_class = EditSupplierPartForm - ajax_template_name = 'modal_form.html' + ajax_template_name = 'company/supplier_part_create.html' ajax_form_title = _('Create new Supplier Part') context_object_name = 'part' role_required = 'purchase_order.add' @@ -304,6 +304,27 @@ class SupplierPartCreate(AjaxCreateView): # TODO - What validation steps can be performed on the single_pricing field? pass + def get_context_data(self): + """ + Supply context data to the form + """ + + ctx = super().get_context_data() + + # Add 'part' object + form = self.get_form() + + part = form['part'].value() + + try: + part = Part.objects.get(pk=part) + except (ValueError, Part.DoesNotExist): + part = None + + ctx['part'] = part + + return ctx + def save(self, form): """ If single_pricing is defined, add a price break for quantity=1