mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 20:45:44 +00:00
Fixes for unit tests
This commit is contained in:
@ -21,7 +21,7 @@ from .models import SalesOrderAllocation
|
||||
|
||||
class IssuePurchaseOrderForm(HelperForm):
|
||||
|
||||
confirm = forms.BooleanField(required=False, help_text=_('Place order'))
|
||||
confirm = forms.BooleanField(required=True, initial=False, help_text=_('Place order'))
|
||||
|
||||
class Meta:
|
||||
model = PurchaseOrder
|
||||
@ -32,7 +32,7 @@ class IssuePurchaseOrderForm(HelperForm):
|
||||
|
||||
class CompletePurchaseOrderForm(HelperForm):
|
||||
|
||||
confirm = forms.BooleanField(required=False, help_text=_("Mark order as complete"))
|
||||
confirm = forms.BooleanField(required=True, help_text=_("Mark order as complete"))
|
||||
|
||||
class Meta:
|
||||
model = PurchaseOrder
|
||||
@ -43,7 +43,7 @@ class CompletePurchaseOrderForm(HelperForm):
|
||||
|
||||
class CancelPurchaseOrderForm(HelperForm):
|
||||
|
||||
confirm = forms.BooleanField(required=False, help_text=_('Cancel order'))
|
||||
confirm = forms.BooleanField(required=True, help_text=_('Cancel order'))
|
||||
|
||||
class Meta:
|
||||
model = PurchaseOrder
|
||||
@ -54,7 +54,7 @@ class CancelPurchaseOrderForm(HelperForm):
|
||||
|
||||
class CancelSalesOrderForm(HelperForm):
|
||||
|
||||
confirm = forms.BooleanField(required=False, help_text=_('Cancel order'))
|
||||
confirm = forms.BooleanField(required=True, help_text=_('Cancel order'))
|
||||
|
||||
class Meta:
|
||||
model = SalesOrder
|
||||
@ -65,7 +65,7 @@ class CancelSalesOrderForm(HelperForm):
|
||||
|
||||
class ShipSalesOrderForm(HelperForm):
|
||||
|
||||
confirm = forms.BooleanField(required=False, help_text=_('Ship order'))
|
||||
confirm = forms.BooleanField(required=True, help_text=_('Ship order'))
|
||||
|
||||
class Meta:
|
||||
model = SalesOrder
|
||||
|
@ -113,6 +113,7 @@ class POTests(OrderViewTestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
data = json.loads(response.content)
|
||||
|
||||
self.assertFalse(data['form_valid'])
|
||||
|
||||
# Test WITH confirmation
|
||||
@ -151,7 +152,6 @@ class POTests(OrderViewTestCase):
|
||||
response = self.client.post(url, post_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
data = json.loads(response.content)
|
||||
self.assertFalse(data['form_valid'])
|
||||
self.assertIn('Invalid Purchase Order', str(data['html_form']))
|
||||
|
||||
# POST with a part that does not match the purchase order
|
||||
post_data['order'] = 1
|
||||
@ -159,14 +159,12 @@ class POTests(OrderViewTestCase):
|
||||
response = self.client.post(url, post_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
data = json.loads(response.content)
|
||||
self.assertFalse(data['form_valid'])
|
||||
self.assertIn('must match for Part and Order', str(data['html_form']))
|
||||
|
||||
# POST with an invalid part
|
||||
post_data['part'] = 12345
|
||||
response = self.client.post(url, post_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
data = json.loads(response.content)
|
||||
self.assertFalse(data['form_valid'])
|
||||
self.assertIn('Invalid SupplierPart selection', str(data['html_form']))
|
||||
|
||||
# POST the form with valid data
|
||||
post_data['part'] = 100
|
||||
|
@ -454,7 +454,7 @@ class PurchaseOrderIssue(AjaxUpdateView):
|
||||
|
||||
def validate(self, order, form, **kwargs):
|
||||
|
||||
confirm = str2bool(form.cleaned_data.get('confirm', False))
|
||||
confirm = str2bool(self.request.POST.get('confirm', False))
|
||||
|
||||
if not confirm:
|
||||
form.add_error('confirm', _('Confirm order placement'))
|
||||
@ -504,6 +504,7 @@ class PurchaseOrderComplete(AjaxUpdateView):
|
||||
'success': _('Purchase order completed')
|
||||
}
|
||||
|
||||
|
||||
class SalesOrderShip(AjaxUpdateView):
|
||||
""" View for 'shipping' a SalesOrder """
|
||||
form_class = order_forms.ShipSalesOrderForm
|
||||
|
Reference in New Issue
Block a user