From cffe2ba84b4c4aafdd332e8fa3a9be11f4fda211 Mon Sep 17 00:00:00 2001 From: Oliver Walters <oliver.henry.walters@gmail.com> Date: Mon, 29 Mar 2021 16:43:26 +1100 Subject: [PATCH] Add a separate form for creating a sales order allocation --- InvenTree/order/forms.py | 29 +++++++++++++++++++++++++++++ InvenTree/order/views.py | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/InvenTree/order/forms.py b/InvenTree/order/forms.py index b5edec386a..06764f2bc9 100644 --- a/InvenTree/order/forms.py +++ b/InvenTree/order/forms.py @@ -211,7 +211,36 @@ class EditSalesOrderLineItemForm(HelperForm): ] +class CreateSalesOrderAllocationForm(HelperForm): + """ + Form for creating a SalesOrderAllocation item. + + This can be allocated by selecting a specific stock item, + or by providing a sequence of serial numbers + """ + + quantity = RoundingDecimalFormField(max_digits = 10, decimal_places=5) + + serials = forms.CharField( + label=_("Serial Numbers"), + required=False, + help_text=_('Enter stock serial numbers'), + ) + + class Meta: + model = SalesOrderAllocation + + fields = [ + 'line', + 'item', + 'quantity', + ] + + class EditSalesOrderAllocationForm(HelperForm): + """ + Form for editing a SalesOrderAllocation item + """ quantity = RoundingDecimalFormField(max_digits=10, decimal_places=5) diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index 2cd8e8a4cb..8b40d6d724 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -1295,7 +1295,7 @@ class SalesOrderAllocationCreate(AjaxCreateView): """ View for creating a new SalesOrderAllocation """ model = SalesOrderAllocation - form_class = order_forms.EditSalesOrderAllocationForm + form_class = order_forms.CreateSalesOrderAllocationForm ajax_form_title = _('Allocate Stock to Order') def get_initial(self):