mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add extra context to SupplierPartCreate form
This commit is contained in:
parent
56f05e2604
commit
5f8f0232a9
@ -0,0 +1,17 @@
|
||||
{% extends "modal_form.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block pre_form_content %}
|
||||
{{ block.super }}
|
||||
|
||||
{% if part %}
|
||||
<div class='alert alert-block alert-info'>
|
||||
{% include "hover_image.html" with image=part.image %}
|
||||
{{ part.full_name}}
|
||||
<br>
|
||||
<i>{{ part.description }}</i>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user