diff --git a/lims_report_html/__init__.py b/lims_report_html/__init__.py index e288e31..55ee268 100644 --- a/lims_report_html/__init__.py +++ b/lims_report_html/__init__.py @@ -5,6 +5,7 @@ from trytond.pool import Pool from . import action from . import html_template +from . import configuration from . import sample from . import analysis from . import results_report @@ -18,6 +19,7 @@ def register(): html_template.ReportTemplateTranslation, html_template.ReportTemplateSection, html_template.ReportTemplateTrendChart, + configuration.Configuration, sample.Fraction, sample.Sample, sample.CreateSampleStart, diff --git a/lims_report_html/configuration.py b/lims_report_html/configuration.py new file mode 100644 index 0000000..26f7533 --- /dev/null +++ b/lims_report_html/configuration.py @@ -0,0 +1,13 @@ +# This file is part of lims_report_html module for Tryton. +# The COPYRIGHT file at the top level of this repository contains +# the full copyright notices and license terms. + +from trytond.model import fields +from trytond.pool import PoolMeta + + +class Configuration(metaclass=PoolMeta): + __name__ = 'lims.configuration' + + result_template = fields.Many2One('lims.result_report.template', + 'Default Report Template', domain=[('type', 'in', [None, 'base'])]) diff --git a/lims_report_html/configuration.xml b/lims_report_html/configuration.xml new file mode 100644 index 0000000..e7cdf1a --- /dev/null +++ b/lims_report_html/configuration.xml @@ -0,0 +1,14 @@ + + + + + + + + lims.configuration + + configuration_form + + + + diff --git a/lims_report_html/locale/es.po b/lims_report_html/locale/es.po index c8f0ab6..9623aec 100644 --- a/lims_report_html/locale/es.po +++ b/lims_report_html/locale/es.po @@ -6,6 +6,10 @@ msgctxt "field:lims.analysis,result_template:" msgid "Report Template" msgstr "Plantilla de Informe" +msgctxt "field:lims.configuration,result_template:" +msgid "Default Report Template" +msgstr "Plantilla de Informe por defecto" + msgctxt "field:lims.create_sample.start,result_template:" msgid "Report Template" msgstr "Plantilla de Informe" @@ -54,6 +58,10 @@ msgctxt "field:lims.result_report.template,name:" msgid "Name" msgstr "Nombre" +msgctxt "field:lims.result_report.template,page_orientation:" +msgid "Page orientation" +msgstr "Orientación de la página" + msgctxt "field:lims.result_report.template,previous_sections:" msgid "Previous Sections" msgstr "Secciones anteriores" @@ -82,10 +90,6 @@ msgctxt "field:lims.result_report.template,type:" msgid "Type" msgstr "Tipo" -msgctxt "field:lims.result_report.template,page_orientation:" -msgid "Page orientation" -msgstr "Orientación de la página" - msgctxt "field:lims.result_report.template.section,data:" msgid "File" msgstr "Archivo" @@ -282,6 +286,14 @@ msgctxt "selection:lims.result_report.template,charts_x_row:" msgid "2" msgstr "2" +msgctxt "selection:lims.result_report.template,page_orientation:" +msgid "Landscape" +msgstr "Horizontal" + +msgctxt "selection:lims.result_report.template,page_orientation:" +msgid "Portrait" +msgstr "Vertical" + msgctxt "selection:lims.result_report.template,type:" msgid "HTML" msgstr "HTML" @@ -294,14 +306,6 @@ msgctxt "selection:lims.result_report.template,type:" msgid "HTML - Header" msgstr "HTML - Encabezado" -msgctxt "selection:lims.result_report.template,page_orientation:" -msgid "Portrait" -msgstr "Vertical" - -msgctxt "selection:lims.result_report.template,page_orientation:" -msgid "Landscape" -msgstr "Horizontal" - msgctxt "selection:lims.result_report.template.section,position:" msgid "Following" msgstr "Siguiente" diff --git a/lims_report_html/results_report.py b/lims_report_html/results_report.py index b990848..f8a05f7 100644 --- a/lims_report_html/results_report.py +++ b/lims_report_html/results_report.py @@ -174,7 +174,10 @@ class ResultsReportVersionDetail(metaclass=PoolMeta): @classmethod def _get_result_template_from_sample(cls, notebook): - Service = Pool().get('lims.service') + pool = Pool() + Service = pool.get('lims.service') + Configuration = pool.get('lims.configuration') + result_template = notebook.fraction.sample.result_template if not result_template: ok = True @@ -193,6 +196,11 @@ class ResultsReportVersionDetail(metaclass=PoolMeta): ok = False if not ok: result_template = None + + if not result_template: + config_ = Configuration(1) + result_template = config_.result_template + return result_template @classmethod diff --git a/lims_report_html/tryton.cfg b/lims_report_html/tryton.cfg index 2de59b9..e5034cb 100644 --- a/lims_report_html/tryton.cfg +++ b/lims_report_html/tryton.cfg @@ -4,6 +4,7 @@ depends: lims xml: html_template.xml + configuration.xml sample.xml analysis.xml results_report.xml diff --git a/lims_report_html/view/configuration_form.xml b/lims_report_html/view/configuration_form.xml new file mode 100644 index 0000000..e787351 --- /dev/null +++ b/lims_report_html/view/configuration_form.xml @@ -0,0 +1,9 @@ + + + + +