mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Prevent calculation of 'allocation_count' before model is saved (#3235)
This commit is contained in:
parent
63b4ff3eb6
commit
9b4e443289
@ -1318,6 +1318,11 @@ class Part(MetadataMixin, MPTTModel):
|
||||
|
||||
def allocation_count(self, **kwargs):
|
||||
"""Return the total quantity of stock allocated for this part, against both build orders and sales orders."""
|
||||
|
||||
if self.id is None:
|
||||
# If this instance has not been saved, foreign-key lookups will fail
|
||||
return 0
|
||||
|
||||
return sum(
|
||||
[
|
||||
self.build_order_allocation_count(**kwargs),
|
||||
|
Loading…
Reference in New Issue
Block a user