mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1682 from matmair/order-modal-show-price
Order modal show price
This commit is contained in:
commit
962badc36d
@ -337,7 +337,7 @@ class AjaxMixin(InvenTreeRoleMixin):
|
|||||||
# Do nothing by default
|
# Do nothing by default
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def renderJsonResponse(self, request, form=None, data={}, context=None):
|
def renderJsonResponse(self, request, form=None, data=None, context=None):
|
||||||
""" Render a JSON response based on specific class context.
|
""" Render a JSON response based on specific class context.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -349,6 +349,9 @@ class AjaxMixin(InvenTreeRoleMixin):
|
|||||||
Returns:
|
Returns:
|
||||||
JSON response object
|
JSON response object
|
||||||
"""
|
"""
|
||||||
|
# a empty dict as default can be dangerous - set it here if empty
|
||||||
|
if not data:
|
||||||
|
data = {}
|
||||||
|
|
||||||
if not request.is_ajax():
|
if not request.is_ajax():
|
||||||
return HttpResponseRedirect('/')
|
return HttpResponseRedirect('/')
|
||||||
|
@ -205,6 +205,13 @@ class InvenTreeSetting(models.Model):
|
|||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'PART_SHOW_PRICE_IN_FORMS': {
|
||||||
|
'name': _('Show Price in Forms'),
|
||||||
|
'description': _('Display part price in some forms'),
|
||||||
|
'default': True,
|
||||||
|
'validator': bool,
|
||||||
|
},
|
||||||
|
|
||||||
'PART_INTERNAL_PRICE': {
|
'PART_INTERNAL_PRICE': {
|
||||||
'name': _('Internal Prices'),
|
'name': _('Internal Prices'),
|
||||||
'description': _('Enable internal prices for parts'),
|
'description': _('Enable internal prices for parts'),
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block form %}
|
{% block form %}
|
||||||
|
{% default_currency as currency %}
|
||||||
|
{% settings_value 'PART_SHOW_PRICE_IN_FORMS' as show_price %}
|
||||||
|
|
||||||
<h4>
|
<h4>
|
||||||
{% trans "Step 1 of 2 - Select Part Suppliers" %}
|
{% trans "Step 1 of 2 - Select Part Suppliers" %}
|
||||||
@ -49,7 +51,13 @@
|
|||||||
<select class='select' id='id_supplier_part_{{ part.id }}' name="part-supplier-{{ part.id }}">
|
<select class='select' id='id_supplier_part_{{ part.id }}' name="part-supplier-{{ part.id }}">
|
||||||
<option value=''>---------</option>
|
<option value=''>---------</option>
|
||||||
{% for supplier in part.supplier_parts.all %}
|
{% for supplier in part.supplier_parts.all %}
|
||||||
<option value="{{ supplier.id }}"{% if part.order_supplier == supplier.id %} selected="selected"{% endif %}>{{ supplier }}</option>
|
<option value="{{ supplier.id }}"{% if part.order_supplier == supplier.id %} selected="selected"{% endif %}>
|
||||||
|
{% if show_price %}
|
||||||
|
{% call_method supplier 'get_price' part.order_quantity as price %}
|
||||||
|
{% if price != None %}{% include "price.html" with price=price %}{% else %}{% trans 'No price' %}{% endif %} -
|
||||||
|
{% endif %}
|
||||||
|
{{ supplier }}
|
||||||
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1004,6 +1004,15 @@ class OrderParts(AjaxView):
|
|||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
""" enrich respone json data """
|
||||||
|
data = super().get_data()
|
||||||
|
# if in selection-phase, add a button to update the prices
|
||||||
|
if getattr(self, 'form_step', 'select_parts') == 'select_parts':
|
||||||
|
data['buttons'] = [{'name': 'update_price', 'title': _('Update prices')}] # set buttons
|
||||||
|
data['hideErrorMessage'] = '1' # hide the error message
|
||||||
|
return data
|
||||||
|
|
||||||
def get_suppliers(self):
|
def get_suppliers(self):
|
||||||
""" Calculates a list of suppliers which the user will need to create POs for.
|
""" Calculates a list of suppliers which the user will need to create POs for.
|
||||||
This is calculated AFTER the user finishes selecting the parts to order.
|
This is calculated AFTER the user finishes selecting the parts to order.
|
||||||
@ -1238,9 +1247,10 @@ class OrderParts(AjaxView):
|
|||||||
valid = False
|
valid = False
|
||||||
|
|
||||||
if form_step == 'select_parts':
|
if form_step == 'select_parts':
|
||||||
# No errors? Proceed to PO selection form
|
# No errors? and the price-update button was not used to submit? Proceed to PO selection form
|
||||||
if part_errors is False:
|
if part_errors is False and 'act-btn_update_price' not in request.POST:
|
||||||
self.ajax_template_name = 'order/order_wizard/select_pos.html'
|
self.ajax_template_name = 'order/order_wizard/select_pos.html'
|
||||||
|
self.form_step = 'select_purchase_orders' # set step (important for get_data)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.ajax_template_name = 'order/order_wizard/select_parts.html'
|
self.ajax_template_name = 'order/order_wizard/select_parts.html'
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
{% include "InvenTree/settings/setting.html" with key="PART_ALLOW_DUPLICATE_IPN" %}
|
{% include "InvenTree/settings/setting.html" with key="PART_ALLOW_DUPLICATE_IPN" %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="PART_ALLOW_EDIT_IPN" %}
|
{% include "InvenTree/settings/setting.html" with key="PART_ALLOW_EDIT_IPN" %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="PART_SHOW_QUANTITY_IN_FORMS" icon="fa-hashtag" %}
|
{% include "InvenTree/settings/setting.html" with key="PART_SHOW_QUANTITY_IN_FORMS" icon="fa-hashtag" %}
|
||||||
|
{% include "InvenTree/settings/setting.html" with key="PART_SHOW_PRICE_IN_FORMS" icon="fa-dollar-sign" %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="PART_RECENT_COUNT" icon="fa-clock" %}
|
{% include "InvenTree/settings/setting.html" with key="PART_RECENT_COUNT" icon="fa-clock" %}
|
||||||
<tr><td colspan='5 '></td></tr>
|
<tr><td colspan='5 '></td></tr>
|
||||||
{% include "InvenTree/settings/setting.html" with key="PART_TEMPLATE" icon="fa-clone" %}
|
{% include "InvenTree/settings/setting.html" with key="PART_TEMPLATE" icon="fa-clone" %}
|
||||||
|
Loading…
Reference in New Issue
Block a user