2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-05 13:10:57 +00:00

client side form for assigning stock items to customers

This commit is contained in:
Oliver
2021-12-09 00:20:45 +11:00
parent c36687af22
commit 96a885e4e1
5 changed files with 168 additions and 54 deletions

View File

@ -294,39 +294,6 @@ class StockLocationQRCode(QRCodeView):
return None
class StockItemAssignToCustomer(AjaxUpdateView):
"""
View for manually assigning a StockItem to a Customer
"""
model = StockItem
ajax_form_title = _("Assign to Customer")
context_object_name = "item"
form_class = StockForms.AssignStockItemToCustomerForm
def validate(self, item, form, **kwargs):
customer = form.cleaned_data.get('customer', None)
if not customer:
form.add_error('customer', _('Customer must be specified'))
def save(self, item, form, **kwargs):
"""
Assign the stock item to the customer.
"""
customer = form.cleaned_data.get('customer', None)
if customer:
item = item.allocateToCustomer(
customer,
user=self.request.user
)
item.clearAllocations()
class StockItemReturnToStock(AjaxUpdateView):
"""
View for returning a stock item (which is assigned to a customer) to stock.