mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
New event triggers (#8226)
- When splitting a stock item - When moving a stock item
This commit is contained in:
parent
fe7bbc2436
commit
c23f2828f5
@ -1921,6 +1921,8 @@ class StockItem(
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
trigger_event('stockitem.split', id=new_stock.id, parent=self.id)
|
||||||
|
|
||||||
# Return a copy of the "new" stock item
|
# Return a copy of the "new" stock item
|
||||||
return new_stock
|
return new_stock
|
||||||
|
|
||||||
@ -1949,6 +1951,8 @@ class StockItem(
|
|||||||
status: If provided, override the status (default = existing status)
|
status: If provided, override the status (default = existing status)
|
||||||
packaging: If provided, override the packaging (default = existing packaging)
|
packaging: If provided, override the packaging (default = existing packaging)
|
||||||
"""
|
"""
|
||||||
|
current_location = self.location
|
||||||
|
|
||||||
try:
|
try:
|
||||||
quantity = Decimal(kwargs.pop('quantity', self.quantity))
|
quantity = Decimal(kwargs.pop('quantity', self.quantity))
|
||||||
except InvalidOperation:
|
except InvalidOperation:
|
||||||
@ -2003,6 +2007,15 @@ class StockItem(
|
|||||||
|
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
# Trigger event for the plugin system
|
||||||
|
trigger_event(
|
||||||
|
'stockitem.moved',
|
||||||
|
id=self.id,
|
||||||
|
old_location=current_location.id if current_location else None,
|
||||||
|
new_location=location.id if location else None,
|
||||||
|
quantity=quantity,
|
||||||
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
@ -2032,6 +2045,7 @@ class StockItem(
|
|||||||
self.delete()
|
self.delete()
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.save()
|
self.save()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user