From cb29ff14e0795f3af2e62081590c2524116aea28 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 10 Feb 2020 21:34:41 +1100 Subject: [PATCH 1/2] Change auto_now field to auto_now_add - Build creation date should no longer get erroneously updated --- .../migrations/0009_auto_20200210_1032.py | 18 ++++++++++++++++++ InvenTree/build/models.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 InvenTree/build/migrations/0009_auto_20200210_1032.py diff --git a/InvenTree/build/migrations/0009_auto_20200210_1032.py b/InvenTree/build/migrations/0009_auto_20200210_1032.py new file mode 100644 index 0000000000..45908933b9 --- /dev/null +++ b/InvenTree/build/migrations/0009_auto_20200210_1032.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.9 on 2020-02-10 10:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('build', '0008_auto_20200201_1247'), + ] + + operations = [ + migrations.AlterField( + model_name='build', + name='creation_date', + field=models.DateField(auto_now_add=True), + ), + ] diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 1ad761a98e..b625dde475 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -82,7 +82,7 @@ class Build(models.Model): batch = models.CharField(max_length=100, blank=True, null=True, help_text=_('Batch code for this build output')) - creation_date = models.DateField(auto_now=True, editable=False) + creation_date = models.DateField(auto_now_add=True, editable=False) completion_date = models.DateField(null=True, blank=True) From 66c1a2ef57d79fe6f7d61dfae8b4bf354745328b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 10 Feb 2020 21:36:57 +1100 Subject: [PATCH 2/2] test fix --- InvenTree/part/test_part.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/part/test_part.py b/InvenTree/part/test_part.py index 28ee93d976..e99a4df6a5 100644 --- a/InvenTree/part/test_part.py +++ b/InvenTree/part/test_part.py @@ -23,7 +23,7 @@ class TemplateTagTest(TestCase): def test_hash(self): hash = inventree_extras.inventree_commit_hash() - self.assertEqual(len(hash), 7) + self.assertGreater(len(hash), 5) def test_date(self): d = inventree_extras.inventree_commit_date()