mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add "revision" number to report model
- Auto-increments whenever the model is saved
This commit is contained in:
parent
af7a627230
commit
33d66182df
@ -1,3 +1,6 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from .models import ReportSnippet, TestReport, ReportAsset
|
|||||||
|
|
||||||
class ReportTemplateAdmin(admin.ModelAdmin):
|
class ReportTemplateAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
list_display = ('name', 'description', 'template', 'filters', 'enabled')
|
list_display = ('name', 'description', 'template', 'filters', 'enabled', 'revision')
|
||||||
|
|
||||||
|
|
||||||
class ReportSnippetAdmin(admin.ModelAdmin):
|
class ReportSnippetAdmin(admin.ModelAdmin):
|
||||||
|
18
InvenTree/report/migrations/0009_testreport_revision.py
Normal file
18
InvenTree/report/migrations/0009_testreport_revision.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2021-02-05 00:53
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('report', '0008_auto_20210204_2100'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='testreport',
|
||||||
|
name='revision',
|
||||||
|
field=models.PositiveIntegerField(default=1, help_text='Report revision number (auto-increments)', verbose_name='Revision'),
|
||||||
|
),
|
||||||
|
]
|
18
InvenTree/report/migrations/0010_auto_20210205_1201.py
Normal file
18
InvenTree/report/migrations/0010_auto_20210205_1201.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2021-02-05 01:01
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('report', '0009_testreport_revision'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='testreport',
|
||||||
|
name='revision',
|
||||||
|
field=models.PositiveIntegerField(default=1, editable=False, help_text='Report revision number (auto-increments)', verbose_name='Revision'),
|
||||||
|
),
|
||||||
|
]
|
@ -62,6 +62,13 @@ class ReportBase(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
|
||||||
|
# Increment revision number
|
||||||
|
self.revision += 1
|
||||||
|
|
||||||
|
super().save()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{n} - {d}".format(n=self.name, d=self.description)
|
return "{n} - {d}".format(n=self.name, d=self.description)
|
||||||
|
|
||||||
@ -113,6 +120,13 @@ class ReportBase(models.Model):
|
|||||||
help_text=_("Report template description")
|
help_text=_("Report template description")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
revision = models.PositiveIntegerField(
|
||||||
|
default=1,
|
||||||
|
verbose_name=_("Revision"),
|
||||||
|
help_text=_("Report revision number (auto-increments)"),
|
||||||
|
editable=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ReportTemplateBase(ReportBase):
|
class ReportTemplateBase(ReportBase):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user