mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
More fixes
This commit is contained in:
parent
6b9145ae56
commit
0fbf39f1bc
@ -1163,7 +1163,16 @@ class Part(MPTTModel):
|
||||
Return the total amount of this part allocated to build orders
|
||||
"""
|
||||
|
||||
query = self.build_order_allocations().aggregate(total=Coalesce(Sum('quantity'), 0))
|
||||
query = self.build_order_allocations().aggregate(
|
||||
total=Coalesce(
|
||||
Sum(
|
||||
'quantity',
|
||||
output_field=models.DecimalField()
|
||||
),
|
||||
0,
|
||||
output_field=models.DecimalField(),
|
||||
)
|
||||
)
|
||||
|
||||
return query['total']
|
||||
|
||||
@ -1179,7 +1188,16 @@ class Part(MPTTModel):
|
||||
Return the tutal quantity of this part allocated to sales orders
|
||||
"""
|
||||
|
||||
query = self.sales_order_allocations().aggregate(total=Coalesce(Sum('quantity'), 0))
|
||||
query = self.sales_order_allocations().aggregate(
|
||||
total=Coalesce(
|
||||
Sum(
|
||||
'quantity',
|
||||
output_field=models.DecimalField(),
|
||||
),
|
||||
0,
|
||||
output_field=models.DecimalField(),
|
||||
)
|
||||
)
|
||||
|
||||
return query['total']
|
||||
|
||||
@ -1194,7 +1212,6 @@ class Part(MPTTModel):
|
||||
self.build_order_allocation_count(),
|
||||
self.sales_order_allocation_count(),
|
||||
],
|
||||
output_field=models.DecimalField()
|
||||
)
|
||||
|
||||
def stock_entries(self, include_variants=True, in_stock=None):
|
||||
|
@ -4,6 +4,7 @@ JSON serializers for Part app
|
||||
import imghdr
|
||||
from decimal import Decimal
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.db.models.functions import Coalesce
|
||||
from InvenTree.serializers import (InvenTreeAttachmentSerializerField,
|
||||
@ -208,7 +209,8 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
queryset = queryset.annotate(
|
||||
in_stock=Coalesce(
|
||||
SubquerySum('stock_items__quantity', filter=StockItem.IN_STOCK_FILTER),
|
||||
Decimal(0)
|
||||
Decimal(0),
|
||||
output_field=models.DecimalField(),
|
||||
),
|
||||
)
|
||||
|
||||
@ -227,6 +229,7 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
building=Coalesce(
|
||||
SubquerySum('builds__quantity', filter=build_filter),
|
||||
Decimal(0),
|
||||
output_field=models.DecimalField(),
|
||||
)
|
||||
)
|
||||
|
||||
@ -240,9 +243,11 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
ordering=Coalesce(
|
||||
SubquerySum('supplier_parts__purchase_order_line_items__quantity', filter=order_filter),
|
||||
Decimal(0),
|
||||
output_field=models.DecimalField(),
|
||||
) - Coalesce(
|
||||
SubquerySum('supplier_parts__purchase_order_line_items__received', filter=order_filter),
|
||||
Decimal(0),
|
||||
output_field=models.DecimalField(),
|
||||
)
|
||||
)
|
||||
|
||||
@ -251,6 +256,7 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
suppliers=Coalesce(
|
||||
SubqueryCount('supplier_parts'),
|
||||
Decimal(0),
|
||||
output_field=models.DecimalField(),
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -57,6 +57,7 @@ class RuleSet(models.Model):
|
||||
'auth_user',
|
||||
'auth_permission',
|
||||
'authtoken_token',
|
||||
'authtoken_tokenproxy',
|
||||
'users_ruleset',
|
||||
],
|
||||
'part_category': [
|
||||
@ -199,7 +200,8 @@ class RuleSet(models.Model):
|
||||
if check_user_role(user, role, permission):
|
||||
return True
|
||||
|
||||
print("failed permission check for", table, permission)
|
||||
# Print message instead of throwing an error
|
||||
print("Failed permission check for", table, permission)
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
|
Loading…
Reference in New Issue
Block a user