2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-14 11:05:41 +00:00

Fixes required for v3.2 compatibility

- Specify DEFAULT_AUTO_FIELD
- Specify output_field for annotations
This commit is contained in:
Oliver Walters
2021-04-20 09:14:08 +10:00
parent 12f1fb9526
commit 6b9145ae56
4 changed files with 19 additions and 7 deletions

View File

@ -52,6 +52,9 @@ def get_setting(environment_var, backup_val, default_value=None):
# Determine if we are running in "test" mode e.g. "manage.py test"
TESTING = 'test' in sys.argv
# New requirement for django 3.2+
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

View File

@ -807,7 +807,13 @@ class Build(MPTTModel):
allocations = self.allocatedItems(part, output)
allocated = allocations.aggregate(q=Coalesce(Sum('quantity'), 0))
allocated = allocations.aggregate(
q=Coalesce(
Sum('quantity'),
0,
output_field=models.DecimalField(),
)
)
return allocated['q']

View File

@ -1189,10 +1189,13 @@ class Part(MPTTModel):
against both build orders and sales orders.
"""
return sum([
self.build_order_allocation_count(),
self.sales_order_allocation_count(),
])
return sum(
[
self.build_order_allocation_count(),
self.sales_order_allocation_count(),
],
output_field=models.DecimalField()
)
def stock_entries(self, include_variants=True, in_stock=None):
""" Return all stock entries for this Part.