mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Custom event when bulk-creating items (#10063)
This commit is contained in:
		| @@ -14,3 +14,5 @@ class StockEvents(BaseEventEnum): | ||||
|     ITEM_COUNTED = 'stockitem.counted' | ||||
|     ITEM_QUANTITY_UPDATED = 'stockitem.quantityupdated' | ||||
|     ITEM_INSTALLED_INTO_ASSEMBLY = 'stockitem.installed' | ||||
|  | ||||
|     ITEMS_CREATED = 'stockitem.created_items' | ||||
|   | ||||
| @@ -650,8 +650,17 @@ class StockItem( | ||||
|             ) | ||||
|             stock.tasks.rebuild_stock_item_tree(parent.tree_id) | ||||
|  | ||||
|         # Fetch the new StockItem objects from the database | ||||
|         items = StockItem.objects.filter(part=part, serial__in=serials) | ||||
|  | ||||
|         # Trigger a 'created' event for the new items | ||||
|         # Note that instead of a single event for each item, | ||||
|         # we trigger a single event for all items created | ||||
|         stock_ids = list(items.values_list('id', flat=True).distinct()) | ||||
|         trigger_event(StockEvents.ITEMS_CREATED, ids=stock_ids) | ||||
|  | ||||
|         # Return the newly created StockItem objects | ||||
|         return StockItem.objects.filter(part=part, serial__in=serials) | ||||
|         return items | ||||
|  | ||||
|     @staticmethod | ||||
|     def convert_serial_to_int(serial: str) -> int: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user