mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Allow non-integer stock movement
This commit is contained in:
parent
e4bfe43c04
commit
9da8189899
18
InvenTree/part/migrations/0025_auto_20191118_2316.py
Normal file
18
InvenTree/part/migrations/0025_auto_20191118_2316.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.2.5 on 2019-11-18 23:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('part', '0024_auto_20191118_2139'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='part',
|
||||
name='units',
|
||||
field=models.CharField(blank=True, default='', help_text='Stock keeping units for this part', max_length=20),
|
||||
),
|
||||
]
|
@ -407,7 +407,7 @@ class Part(models.Model):
|
||||
|
||||
minimum_stock = models.PositiveIntegerField(default=0, validators=[MinValueValidator(0)], help_text=_('Minimum allowed stock level'))
|
||||
|
||||
units = models.CharField(max_length=20, default="pcs", blank=True, help_text=_('Stock keeping units for this part'))
|
||||
units = models.CharField(max_length=20, default="", blank=True, help_text=_('Stock keeping units for this part'))
|
||||
|
||||
assembly = models.BooleanField(default=False, verbose_name='Assembly', help_text=_('Can this part be built from other parts?'))
|
||||
|
||||
|
19
InvenTree/stock/migrations/0017_auto_20191118_2311.py
Normal file
19
InvenTree/stock/migrations/0017_auto_20191118_2311.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 2.2.5 on 2019-11-18 23:11
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stock', '0016_auto_20191118_2146'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='stockitemtracking',
|
||||
name='quantity',
|
||||
field=models.DecimalField(decimal_places=5, default=1, max_digits=15, validators=[django.core.validators.MinValueValidator(0)]),
|
||||
),
|
||||
]
|
@ -511,6 +511,11 @@ class StockItem(models.Model):
|
||||
if self.serialized:
|
||||
return
|
||||
|
||||
try:
|
||||
quantity = Decimal(quantity)
|
||||
except (InvalidOperation, ValueError):
|
||||
return
|
||||
|
||||
# Doesn't make sense for a zero quantity
|
||||
if quantity <= 0:
|
||||
return
|
||||
@ -603,12 +608,17 @@ class StockItem(models.Model):
|
||||
if self.serialized:
|
||||
return
|
||||
|
||||
try:
|
||||
self.quantity = Decimal(quantity)
|
||||
except (InvalidOperation, ValueError):
|
||||
return
|
||||
|
||||
if quantity < 0:
|
||||
quantity = 0
|
||||
|
||||
self.quantity = quantity
|
||||
|
||||
if quantity <= 0 and self.delete_on_deplete and self.can_delete():
|
||||
if quantity == 0 and self.delete_on_deplete and self.can_delete():
|
||||
|
||||
# TODO - Do not actually "delete" stock at this point - instead give it a "DELETED" flag
|
||||
self.delete()
|
||||
return False
|
||||
else:
|
||||
@ -745,7 +755,7 @@ class StockItemTracking(models.Model):
|
||||
|
||||
system = models.BooleanField(default=False)
|
||||
|
||||
quantity = models.PositiveIntegerField(validators=[MinValueValidator(0)], default=1)
|
||||
quantity = models.DecimalField(max_digits=15, decimal_places=5, validators=[MinValueValidator(0)], default=1)
|
||||
|
||||
# TODO
|
||||
# image = models.ImageField(upload_to=func, max_length=255, null=True, blank=True)
|
||||
|
@ -546,7 +546,7 @@ class StockAdjust(AjaxView, FormMixin):
|
||||
if destination == item.location and item.new_quantity == item.quantity:
|
||||
continue
|
||||
|
||||
item.move(destination, note, self.request.user, quantity=int(item.new_quantity))
|
||||
item.move(destination, note, self.request.user, quantity=item.new_quantity)
|
||||
|
||||
count += 1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user