2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

make operators simpler

This commit is contained in:
Matthias
2022-05-15 17:52:23 +02:00
parent af8bddf690
commit 77aeecf23a
12 changed files with 25 additions and 25 deletions

View File

@ -404,7 +404,7 @@ class StockItem(MPTTModel):
deltas = {}
# Status changed?
if not old.status == self.status:
if old.status != self.status:
deltas['status'] = self.status
# TODO - Other interesting changes we are interested in...
@ -493,7 +493,7 @@ class StockItem(MPTTModel):
try:
if self.part.trackable:
# Trackable parts must have integer values for quantity field!
if not self.quantity == int(self.quantity):
if self.quantity != int(self.quantity):
raise ValidationError({
'quantity': _('Quantity must be integer value for trackable parts')
})
@ -511,7 +511,7 @@ class StockItem(MPTTModel):
# The 'supplier_part' field must point to the same part!
try:
if self.supplier_part is not None:
if not self.supplier_part.part == self.part:
if self.supplier_part.part != self.part:
raise ValidationError({'supplier_part': _("Part type ('{pf}') must be {pe}").format(
pf=str(self.supplier_part.part),
pe=str(self.part))
@ -1314,10 +1314,10 @@ class StockItem(MPTTModel):
if quantity > self.quantity:
raise ValidationError({"quantity": _("Quantity must not exceed available stock quantity ({n})").format(n=self.quantity)})
if not type(serials) in [list, tuple]:
if type(serials) not in [list, tuple]:
raise ValidationError({"serial_numbers": _("Serial numbers must be a list of integers")})
if not quantity == len(serials):
if quantity != len(serials):
raise ValidationError({"quantity": _("Quantity does not match serial numbers")})
# Test if each of the serial numbers are valid