mirror of
https://github.com/inventree/InvenTree.git
synced 2025-12-14 08:19:54 +00:00
Return from customer (#3120)
* Adds ability to return item into stock via the API * Remove old server-side form / view for returning stock from a customer * Add unit tests for new API endpoint
This commit is contained in:
@@ -125,35 +125,6 @@ class StockLocationQRCode(QRCodeView):
|
||||
return None
|
||||
|
||||
|
||||
class StockItemReturnToStock(AjaxUpdateView):
|
||||
"""View for returning a stock item (which is assigned to a customer) to stock."""
|
||||
|
||||
model = StockItem
|
||||
ajax_form_title = _("Return to Stock")
|
||||
context_object_name = "item"
|
||||
form_class = StockForms.ReturnStockItemForm
|
||||
|
||||
def validate(self, item, form, **kwargs):
|
||||
"""Make sure required data is there."""
|
||||
location = form.cleaned_data.get('location', None)
|
||||
|
||||
if not location:
|
||||
form.add_error('location', _('Specify a valid location'))
|
||||
|
||||
def save(self, item, form, **kwargs):
|
||||
"""Return stock."""
|
||||
location = form.cleaned_data.get('location', None)
|
||||
|
||||
if location:
|
||||
item.returnFromCustomer(location, self.request.user)
|
||||
|
||||
def get_data(self):
|
||||
"""Set success message."""
|
||||
return {
|
||||
'success': _('Stock item returned from customer')
|
||||
}
|
||||
|
||||
|
||||
class StockItemDeleteTestData(AjaxUpdateView):
|
||||
"""View for deleting all test data."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user