mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add default page size for reports
- A4 / Legal / Letter - Use this for the default page size for InvenTree reports
This commit is contained in:
parent
2aa2f08658
commit
dbaa0fc300
@ -174,6 +174,17 @@ class InvenTreeSetting(models.Model):
|
||||
'validator': bool,
|
||||
},
|
||||
|
||||
'REPORT_DEFAULT_PAGE_SIZE': {
|
||||
'name': _('Page Size'),
|
||||
'description': _('Default page size for PDF reports'),
|
||||
'default': 'A4',
|
||||
'choices': [
|
||||
('A4', 'A4'),
|
||||
('Legal', 'Legal'),
|
||||
('Letter', 'Letter')
|
||||
],
|
||||
},
|
||||
|
||||
'REPORT_ENABLE_TEST_REPORT': {
|
||||
'name': _('Test Reports'),
|
||||
'description': _('Enable generation of test reports'),
|
||||
|
@ -18,6 +18,7 @@ from django.core.files.storage import FileSystemStorage
|
||||
from django.core.validators import FileExtensionValidator
|
||||
|
||||
import stock.models
|
||||
import common.models
|
||||
|
||||
from InvenTree.helpers import validateFilterString
|
||||
|
||||
@ -186,15 +187,14 @@ class ReportTemplateBase(ReportBase):
|
||||
|
||||
context = self.get_context_data(request)
|
||||
|
||||
context['media'] = settings.MEDIA_ROOT
|
||||
|
||||
context['report_name'] = self.name
|
||||
context['date'] = datetime.datetime.now().date()
|
||||
context['datetime'] = datetime.datetime.now()
|
||||
context['default_page_size'] = common.models.InvenTreeSetting.get_setting('REPORT_DEFAULT_PAGE_SIZE')
|
||||
context['report_description'] = self.description
|
||||
context['report_name'] = self.name
|
||||
context['report_revision'] = self.revision
|
||||
context['request'] = request
|
||||
context['user'] = request.user
|
||||
context['date'] = datetime.datetime.now().date()
|
||||
context['datetime'] = datetime.datetime.now()
|
||||
|
||||
# Render HTML template to PDF
|
||||
wp = WeasyprintReportMixin(
|
||||
|
@ -3,14 +3,12 @@
|
||||
<head>
|
||||
<style>
|
||||
@page {
|
||||
{% block page_size %}
|
||||
size: A4;
|
||||
{% endblock %}
|
||||
{% block page_margin %}
|
||||
margin: 2cm;
|
||||
{% endblock %}
|
||||
{% block page_style %}
|
||||
size: {% block page_size %}{{ default_page_size }}{% endblock %};
|
||||
margin: {% block page_margin %}2cm{% endblock %};
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 75%;
|
||||
{% endblock %}
|
||||
|
||||
@top-left {
|
||||
{% block top_left %}
|
||||
@ -45,7 +43,9 @@
|
||||
}
|
||||
|
||||
body {
|
||||
{% block body_style %}
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
{% endblock %}
|
||||
}
|
||||
|
||||
.header {
|
||||
|
@ -15,6 +15,7 @@
|
||||
<table class='table table-striped table-condensed'>
|
||||
{% include "InvenTree/settings/header.html" %}
|
||||
<tbody>
|
||||
{% include "InvenTree/settings/setting.html" with key="REPORT_DEFAULT_PAGE_SIZE" %}
|
||||
{% include "InvenTree/settings/setting.html" with key="REPORT_ENABLE_TEST_REPORT" %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user