mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add "report" app
- Define ReportTemplate model which contains a report file template
This commit is contained in:
parent
5018f899f7
commit
3d8c059a43
@ -106,12 +106,13 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
|
||||||
# InvenTree apps
|
# InvenTree apps
|
||||||
'common.apps.CommonConfig',
|
|
||||||
'part.apps.PartConfig',
|
|
||||||
'stock.apps.StockConfig',
|
|
||||||
'company.apps.CompanyConfig',
|
|
||||||
'build.apps.BuildConfig',
|
'build.apps.BuildConfig',
|
||||||
|
'common.apps.CommonConfig',
|
||||||
|
'company.apps.CompanyConfig',
|
||||||
'order.apps.OrderConfig',
|
'order.apps.OrderConfig',
|
||||||
|
'part.apps.PartConfig',
|
||||||
|
'report.apps.ReportConfig',
|
||||||
|
'stock.apps.StockConfig',
|
||||||
|
|
||||||
# Third part add-ons
|
# Third part add-ons
|
||||||
'django_filters', # Extended filter functionality
|
'django_filters', # Extended filter functionality
|
||||||
|
0
InvenTree/report/__init__.py
Normal file
0
InvenTree/report/__init__.py
Normal file
14
InvenTree/report/admin.py
Normal file
14
InvenTree/report/admin.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .models import ReportTemplate
|
||||||
|
|
||||||
|
|
||||||
|
class ReportTemplateAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
|
list_display = ('template', 'description')
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(ReportTemplate, ReportTemplateAdmin)
|
5
InvenTree/report/apps.py
Normal file
5
InvenTree/report/apps.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ReportConfig(AppConfig):
|
||||||
|
name = 'report'
|
23
InvenTree/report/migrations/0001_initial.py
Normal file
23
InvenTree/report/migrations/0001_initial.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.0.5 on 2020-05-21 03:43
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import report.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ReportTemplate',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('template', models.FileField(help_text='Report template file', upload_to=report.models.rename_template)),
|
||||||
|
('description', models.CharField(help_text='Report template description', max_length=250)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
20
InvenTree/report/migrations/0002_auto_20200521_0350.py
Normal file
20
InvenTree/report/migrations/0002_auto_20200521_0350.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 3.0.5 on 2020-05-21 03:50
|
||||||
|
|
||||||
|
import django.core.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
import report.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('report', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='reporttemplate',
|
||||||
|
name='template',
|
||||||
|
field=models.FileField(help_text='Report template file', upload_to=report.models.rename_template, validators=[django.core.validators.FileExtensionValidator(allowed_extensions=['html', 'tex'])]),
|
||||||
|
),
|
||||||
|
]
|
0
InvenTree/report/migrations/__init__.py
Normal file
0
InvenTree/report/migrations/__init__.py
Normal file
36
InvenTree/report/models.py
Normal file
36
InvenTree/report/models.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
"""
|
||||||
|
Report template model definitions
|
||||||
|
"""
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
from django.core.validators import FileExtensionValidator
|
||||||
|
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
def rename_template(instance, filename):
|
||||||
|
|
||||||
|
filename = os.path.basename(filename)
|
||||||
|
|
||||||
|
return os.path.join('report', 'template', filename)
|
||||||
|
|
||||||
|
class ReportTemplate(models.Model):
|
||||||
|
"""
|
||||||
|
Reporting template model.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return os.path.basename(self.template.name)
|
||||||
|
|
||||||
|
template = models.FileField(
|
||||||
|
upload_to=rename_template,
|
||||||
|
help_text=_("Report template file"),
|
||||||
|
validators=[FileExtensionValidator(allowed_extensions=['html', 'tex'])],
|
||||||
|
)
|
||||||
|
|
||||||
|
description = models.CharField(max_length=250, help_text=_("Report template description"))
|
3
InvenTree/report/tests.py
Normal file
3
InvenTree/report/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
3
InvenTree/report/views.py
Normal file
3
InvenTree/report/views.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
4
Makefile
4
Makefile
@ -51,12 +51,12 @@ style:
|
|||||||
# Run unit tests
|
# Run unit tests
|
||||||
test:
|
test:
|
||||||
cd InvenTree && python3 manage.py check
|
cd InvenTree && python3 manage.py check
|
||||||
cd InvenTree && python3 manage.py test build common company order part stock
|
cd InvenTree && python3 manage.py test build common company order part report stock InvenTree
|
||||||
|
|
||||||
# Run code coverage
|
# Run code coverage
|
||||||
coverage:
|
coverage:
|
||||||
cd InvenTree && python3 manage.py check
|
cd InvenTree && python3 manage.py check
|
||||||
coverage run InvenTree/manage.py test build common company order part stock InvenTree
|
coverage run InvenTree/manage.py test build common company order part report stock InvenTree
|
||||||
coverage html
|
coverage html
|
||||||
|
|
||||||
# Install packages required to generate code docs
|
# Install packages required to generate code docs
|
||||||
|
Loading…
Reference in New Issue
Block a user