mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Database filtering beats list comprehension!
This commit is contained in:
parent
6854190ff9
commit
59f102af3c
@ -5,6 +5,7 @@ Order model definitions
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
|
from django.db.models import F
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
@ -226,7 +227,7 @@ class PurchaseOrder(Order):
|
|||||||
Any line item where 'received' < 'quantity' will be returned.
|
Any line item where 'received' < 'quantity' will be returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return [line for line in self.lines.all() if line.quantity > line.received]
|
return self.lines.filter(quantity__gt=F('received'))
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def receive_line_item(self, line, location, quantity, user):
|
def receive_line_item(self, line, location, quantity, user):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user