update-button for modal, repeat 1st step on use

This commit is contained in:
Matthias 2021-06-17 23:24:32 +02:00
parent 2d8b96a6b8
commit a3a623a5ca

View File

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