mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 03:30:54 +00:00
Improved 'move stock' form
- Better error checking on the form (provides form validation messages to user)
This commit is contained in:
@ -217,21 +217,24 @@ class StockItem(models.Model):
|
||||
track.save()
|
||||
|
||||
@transaction.atomic
|
||||
def move(self, location, user):
|
||||
def move(self, location, notes, user):
|
||||
|
||||
if location == self.location:
|
||||
return
|
||||
if location.pk == self.location.pk:
|
||||
return False # raise forms.ValidationError("Cannot move item to its current location")
|
||||
|
||||
note = "Moved to {loc}".format(loc=location.name)
|
||||
msg = "Moved to {loc} (from {src})".format(loc=location.name,
|
||||
src=self.location.name)
|
||||
|
||||
self.location = location
|
||||
self.save()
|
||||
|
||||
self.add_transaction_note('Transfer',
|
||||
self.add_transaction_note(msg,
|
||||
user,
|
||||
notes=note,
|
||||
notes=notes,
|
||||
system=True)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
def stocktake(self, count, user, notes=''):
|
||||
|
Reference in New Issue
Block a user