mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-04 14:28:48 +00:00
Add ITEM_RECEIVED event (#8651)
* Add ITEM_RECEIVED event - Triggered when an item is recevied against a purchase order * Adjust unit test
This commit is contained in:
parent
4a8cb6f7f3
commit
64dc5659bc
@ -13,6 +13,8 @@ class PurchaseOrderEvents(BaseEventEnum):
|
|||||||
|
|
||||||
OVERDUE = 'order.overdue_purchase_order'
|
OVERDUE = 'order.overdue_purchase_order'
|
||||||
|
|
||||||
|
ITEM_RECEIVED = 'purchaseorderitem.received'
|
||||||
|
|
||||||
|
|
||||||
class SalesOrderEvents(BaseEventEnum):
|
class SalesOrderEvents(BaseEventEnum):
|
||||||
"""Event enumeration for the SalesOrder models."""
|
"""Event enumeration for the SalesOrder models."""
|
||||||
|
@ -883,6 +883,10 @@ class PurchaseOrder(TotalPriceMixin, Order):
|
|||||||
quantity=float(quantity),
|
quantity=float(quantity),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
trigger_event(
|
||||||
|
PurchaseOrderEvents.ITEM_RECEIVED, order_id=self.pk, item_id=self.pk
|
||||||
|
)
|
||||||
|
|
||||||
# Update the number of parts received against the particular line item
|
# Update the number of parts received against the particular line item
|
||||||
# Note that this quantity does *not* take the pack_quantity into account, it is "number of packs"
|
# Note that this quantity does *not* take the pack_quantity into account, it is "number of packs"
|
||||||
line.received += quantity
|
line.received += quantity
|
||||||
|
@ -1168,7 +1168,8 @@ class PurchaseOrderReceiveTest(OrderTest):
|
|||||||
|
|
||||||
n = StockItem.objects.count()
|
n = StockItem.objects.count()
|
||||||
|
|
||||||
self.post(self.url, data, expected_code=201, max_query_count=400)
|
# TODO: 2024-12-10 - This API query needs to be refactored!
|
||||||
|
self.post(self.url, data, expected_code=201, max_query_count=500)
|
||||||
|
|
||||||
# Check that the expected number of stock items has been created
|
# Check that the expected number of stock items has been created
|
||||||
self.assertEqual(n + 11, StockItem.objects.count())
|
self.assertEqual(n + 11, StockItem.objects.count())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user