mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-30 18:50:53 +00:00
Merge remote-tracking branch 'inventree/master' into multi-db-unit-test
# Conflicts: # InvenTree/build/test_build.py
This commit is contained in:
18
InvenTree/stock/migrations/0050_auto_20200821_1403.py
Normal file
18
InvenTree/stock/migrations/0050_auto_20200821_1403.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.7 on 2020-08-21 14:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stock', '0049_auto_20200820_0454'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='stockitem',
|
||||
name='serial',
|
||||
field=models.CharField(blank=True, help_text='Serial number for this item', max_length=100, null=True, verbose_name='Serial Number'),
|
||||
),
|
||||
]
|
@ -355,9 +355,9 @@ class StockItem(MPTTModel):
|
||||
verbose_name=_("Customer"),
|
||||
)
|
||||
|
||||
serial = models.PositiveIntegerField(
|
||||
serial = models.CharField(
|
||||
verbose_name=_('Serial Number'),
|
||||
blank=True, null=True,
|
||||
max_length=100, blank=True, null=True,
|
||||
help_text=_('Serial number for this item')
|
||||
)
|
||||
|
||||
@ -687,9 +687,6 @@ class StockItem(MPTTModel):
|
||||
if not type(serials) in [list, tuple]:
|
||||
raise ValidationError({"serial_numbers": _("Serial numbers must be a list of integers")})
|
||||
|
||||
if any([type(i) is not int for i in serials]):
|
||||
raise ValidationError({"serial_numbers": _("Serial numbers must be a list of integers")})
|
||||
|
||||
if not quantity == len(serials):
|
||||
raise ValidationError({"quantity": _("Quantity does not match serial numbers")})
|
||||
|
||||
|
@ -113,7 +113,7 @@ class StockItemSerializer(InvenTreeModelSerializer):
|
||||
|
||||
allocated = serializers.FloatField(source='allocation_count', required=False)
|
||||
|
||||
serial = serializers.IntegerField(required=False)
|
||||
serial = serializers.CharField(required=False)
|
||||
|
||||
required_tests = serializers.IntegerField(source='required_test_count', read_only=True, required=False)
|
||||
|
||||
|
1
InvenTree/stock/templates/stock/stock_move.html
Normal file
1
InvenTree/stock/templates/stock/stock_move.html
Normal file
@ -0,0 +1 @@
|
||||
{% extends "modal_form.html" %}
|
@ -295,10 +295,7 @@ class StockTest(TestCase):
|
||||
with self.assertRaises(ValidationError):
|
||||
item.serializeStock(-1, [], self.user)
|
||||
|
||||
# Try invalid serial numbers
|
||||
with self.assertRaises(ValidationError):
|
||||
item.serializeStock(3, [1, 2, 'k'], self.user)
|
||||
|
||||
# Not enough serial numbers for all stock items.
|
||||
with self.assertRaises(ValidationError):
|
||||
item.serializeStock(3, "hello", self.user)
|
||||
|
||||
@ -375,14 +372,14 @@ class VariantTest(StockTest):
|
||||
|
||||
self.assertFalse(chair.checkIfSerialNumberExists(30))
|
||||
|
||||
self.assertEqual(chair.getNextSerialNumber(), 23)
|
||||
self.assertEqual(chair.getLatestSerialNumber(), '22')
|
||||
|
||||
# Same operations on a sub-item
|
||||
variant = Part.objects.get(pk=10003)
|
||||
self.assertEqual(variant.getNextSerialNumber(), 23)
|
||||
self.assertEqual(variant.getLatestSerialNumber(), '22')
|
||||
|
||||
# Create a new serial number
|
||||
n = variant.getHighestSerialNumber()
|
||||
n = variant.getLatestSerialNumber()
|
||||
|
||||
item = StockItem(
|
||||
part=variant,
|
||||
@ -394,8 +391,14 @@ class VariantTest(StockTest):
|
||||
with self.assertRaises(ValidationError):
|
||||
item.save()
|
||||
|
||||
# This should pass
|
||||
item.serial = n + 1
|
||||
# Verify items with a non-numeric serial don't offer a next serial.
|
||||
item.serial = "string"
|
||||
item.save()
|
||||
|
||||
self.assertEqual(variant.getLatestSerialNumber(), "string")
|
||||
|
||||
# This should pass, although not strictly an int field now.
|
||||
item.serial = int(n) + 1
|
||||
item.save()
|
||||
|
||||
# Attempt to create the same serial number but for a variant (should fail!)
|
||||
|
@ -1234,8 +1234,9 @@ class StockItemCreate(AjaxCreateView):
|
||||
part = self.get_part(form=form)
|
||||
|
||||
if part is not None:
|
||||
sn = part.getNextSerialNumber()
|
||||
form.field_placeholder['serial_numbers'] = _('Next available serial number is') + ' ' + str(sn)
|
||||
|
||||
# Add placeholder text for the serial number field
|
||||
form.field_placeholder['serial_numbers'] = part.getSerialNumberString()
|
||||
|
||||
form.rebuild_layout()
|
||||
|
||||
@ -1353,11 +1354,6 @@ class StockItemCreate(AjaxCreateView):
|
||||
part = Part.objects.get(id=part_id)
|
||||
quantity = Decimal(form['quantity'].value())
|
||||
|
||||
sn = part.getNextSerialNumber()
|
||||
form.field_placeholder['serial_numbers'] = _("Next available serial number is") + " " + str(sn)
|
||||
|
||||
form.rebuild_layout()
|
||||
|
||||
except (Part.DoesNotExist, ValueError, InvalidOperation):
|
||||
part = None
|
||||
quantity = 1
|
||||
|
Reference in New Issue
Block a user