diff --git a/lims_diagnosis/locale/es.po b/lims_diagnosis/locale/es.po index 0b46070..ad6274f 100644 --- a/lims_diagnosis/locale/es.po +++ b/lims_diagnosis/locale/es.po @@ -320,10 +320,6 @@ msgctxt "selection:lims.results_report.version.detail,state:" msgid "Diagnosed" msgstr "Diagnosticado" -msgctxt "view:lims.analysis:" -msgid "Diagnosis" -msgstr "Diagnóstico" - msgctxt "view:lims.diagnosis.state:" msgid "Options" msgstr "Opciones" diff --git a/lims_diagnosis/view/analysis_form.xml b/lims_diagnosis/view/analysis_form.xml index 19aec33..89f86dd 100644 --- a/lims_diagnosis/view/analysis_form.xml +++ b/lims_diagnosis/view/analysis_form.xml @@ -1,11 +1,9 @@ - - - + + diff --git a/lims_report_html/__init__.py b/lims_report_html/__init__.py index 33eb813..0ae13eb 100644 --- a/lims_report_html/__init__.py +++ b/lims_report_html/__init__.py @@ -6,6 +6,7 @@ from trytond.pool import Pool from . import action from . import html_template from . import sample +from . import analysis from . import results_report from . import notebook @@ -19,6 +20,7 @@ def register(): html_template.ReportTemplateTrendChart, sample.Sample, sample.CreateSampleStart, + analysis.Analysis, results_report.ResultsReportVersionDetail, results_report.ResultsReportVersionDetailSection, results_report.ResultsReportVersionDetailTrendChart, diff --git a/lims_report_html/analysis.py b/lims_report_html/analysis.py new file mode 100644 index 0000000..1cac012 --- /dev/null +++ b/lims_report_html/analysis.py @@ -0,0 +1,16 @@ +# 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 +from trytond.pyson import Eval + + +class Analysis(metaclass=PoolMeta): + __name__ = 'lims.analysis' + + result_template = fields.Many2One('lims.result_report.template', + 'Report Template', domain=[('type', 'in', [None, 'base'])], + states={'readonly': Eval('type') != 'group'}, + depends=['type']) diff --git a/lims_report_html/analysis.xml b/lims_report_html/analysis.xml new file mode 100644 index 0000000..82c66fe --- /dev/null +++ b/lims_report_html/analysis.xml @@ -0,0 +1,14 @@ + + + + + + + + lims.analysis + + analysis_form + + + + diff --git a/lims_report_html/locale/es.po b/lims_report_html/locale/es.po index a62053d..57fb4f8 100644 --- a/lims_report_html/locale/es.po +++ b/lims_report_html/locale/es.po @@ -2,6 +2,10 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" +msgctxt "field:lims.analysis,result_template:" +msgid "Report Template" +msgstr "Plantilla de Informe" + msgctxt "field:lims.create_sample.start,result_template:" msgid "Report Template" msgstr "Plantilla de Informe" @@ -286,6 +290,10 @@ msgctxt "selection:lims.results_report.version.detail.section,position:" msgid "Previous" msgstr "Anterior" +msgctxt "view:lims.analysis:" +msgid "Report" +msgstr "Informe" + msgctxt "view:lims.result_report.template:" msgid "Header and Footer" msgstr "Encabezado y Pie de página" diff --git a/lims_report_html/results_report.py b/lims_report_html/results_report.py index 44156c3..8cbb69c 100644 --- a/lims_report_html/results_report.py +++ b/lims_report_html/results_report.py @@ -104,7 +104,7 @@ class ResultsReportVersionDetail(metaclass=PoolMeta): detail_default = super()._get_fields_from_samples(samples) for sample in samples: notebook = Notebook(sample['notebook']) - result_template = notebook.fraction.sample.result_template + result_template = cls._get_result_template_from_sample(notebook) if result_template: detail_default['template'] = result_template.id if result_template.trend_charts: @@ -127,6 +127,27 @@ class ResultsReportVersionDetail(metaclass=PoolMeta): detail_default['resultrange_origin'] = resultrange_origin.id return detail_default + @classmethod + def _get_result_template_from_sample(cls, notebook): + Service = Pool().get('lims.service') + result_template = notebook.fraction.sample.result_template + if not result_template: + ok = True + services = Service.search([ + ('fraction', '=', notebook.fraction), + ]) + for service in services: + if service.analysis.result_template: + if not result_template: + result_template = service.analysis.result_template + elif result_template != service.analysis.result_template: + ok = False + elif result_template: + ok = False + if not ok: + result_template = None + return result_template + @classmethod def _get_fields_from_detail(cls, detail): detail_default = super()._get_fields_from_detail(detail) diff --git a/lims_report_html/tryton.cfg b/lims_report_html/tryton.cfg index 3c86ea5..82f37ac 100644 --- a/lims_report_html/tryton.cfg +++ b/lims_report_html/tryton.cfg @@ -5,5 +5,6 @@ depends: xml: html_template.xml sample.xml + analysis.xml results_report.xml message.xml diff --git a/lims_report_html/view/analysis_form.xml b/lims_report_html/view/analysis_form.xml new file mode 100644 index 0000000..98c047e --- /dev/null +++ b/lims_report_html/view/analysis_form.xml @@ -0,0 +1,9 @@ + + + + + + +