From cdaba55c14b99ea7ea9023ad4f1513811f6edab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Bernardi?= Date: Sat, 7 May 2022 17:45:37 -0300 Subject: [PATCH] lims_report_html, lims_diagnosis: report template refactoring --- lims_diagnosis/__init__.py | 2 +- lims_diagnosis/html_template.py | 11 +- lims_diagnosis/html_template.xml | 8 +- lims_diagnosis/locale/es.po | 6 +- lims_diagnosis/results_report.py | 11 +- ...late_form.xml => result_template_form.xml} | 2 +- lims_report_html/__init__.py | 3 +- lims_report_html/action.py | 17 +- lims_report_html/analysis.py | 7 +- lims_report_html/configuration.py | 7 +- lims_report_html/html_template.py | 573 ++++++++++++++++-- lims_report_html/html_template.xml | 83 +-- lims_report_html/laboratory.py | 7 +- lims_report_html/locale/es.po | 110 ++-- lims_report_html/message.xml | 3 + lims_report_html/notebook.py | 2 +- lims_report_html/party.py | 7 +- lims_report_html/results_report.py | 387 +----------- lims_report_html/results_report.xml | 4 +- lims_report_html/sample.py | 16 +- lims_report_html/view/analysis_form.xml | 3 +- lims_report_html/view/configuration_form.xml | 3 +- .../view/create_sample_start_form.xml | 3 +- lims_report_html/view/laboratory_form.xml | 3 +- .../notebook_generate_results_report_form.xml | 3 +- lims_report_html/view/party_party_form.xml | 3 +- ...late_form.xml => result_template_form.xml} | 10 +- ...late_list.xml => result_template_list.xml} | 0 .../results_report_version_detail_form.xml | 11 +- lims_report_html/view/sample_form.xml | 3 +- 30 files changed, 757 insertions(+), 551 deletions(-) rename lims_diagnosis/view/{template_form.xml => result_template_form.xml} (79%) rename lims_report_html/view/{template_form.xml => result_template_form.xml} (78%) rename lims_report_html/view/{template_list.xml => result_template_list.xml} (100%) diff --git a/lims_diagnosis/__init__.py b/lims_diagnosis/__init__.py index baad2aa..7a12995 100644 --- a/lims_diagnosis/__init__.py +++ b/lims_diagnosis/__init__.py @@ -24,7 +24,7 @@ def register(): html_template.DiagnosisStateImage, html_template.DiagnosisTemplate, html_template.DiagnosisTemplateState, - html_template.ReportTemplate, + html_template.ResultsReportTemplate, sample.Fraction, sample.Sample, sample.CreateSampleStart, diff --git a/lims_diagnosis/html_template.py b/lims_diagnosis/html_template.py index 7d5cb9d..ec4b116 100644 --- a/lims_diagnosis/html_template.py +++ b/lims_diagnosis/html_template.py @@ -4,6 +4,7 @@ from trytond.model import ModelSQL, ModelView, fields, DictSchemaMixin from trytond.pool import PoolMeta +from trytond.pyson import Eval class DiagnosisTemplate(ModelSQL, ModelView): @@ -51,10 +52,14 @@ class DiagnosisTemplateState(ModelSQL): required=True, ondelete='CASCADE', select=True) -class ReportTemplate(metaclass=PoolMeta): - __name__ = 'lims.result_report.template' +class ResultsReportTemplate(metaclass=PoolMeta): + __name__ = 'lims.report.template' diagnosis_template = fields.Many2One('lims.diagnosis.template', - 'Diagnosis Template') + 'Diagnosis Template', + states={'invisible': Eval('type') != 'base'}, + depends=['type']) diagnosis_length = fields.Integer('Diagnosis Length', + states={'invisible': Eval('type') != 'base'}, + depends=['type'], help='Maximum number of characters in diagnosis') diff --git a/lims_diagnosis/html_template.xml b/lims_diagnosis/html_template.xml index 84a75bb..397cf22 100644 --- a/lims_diagnosis/html_template.xml +++ b/lims_diagnosis/html_template.xml @@ -86,10 +86,10 @@ - - lims.result_report.template - - template_form + + lims.report.template + + result_template_form diff --git a/lims_diagnosis/locale/es.po b/lims_diagnosis/locale/es.po index 3bea950..96514c8 100644 --- a/lims_diagnosis/locale/es.po +++ b/lims_diagnosis/locale/es.po @@ -110,11 +110,11 @@ msgctxt "field:lims.product.type,diagnostician:" msgid "Diagnostician" msgstr "Diagnosticador" -msgctxt "field:lims.result_report.template,diagnosis_length:" +msgctxt "field:lims.report.template,diagnosis_length:" msgid "Diagnosis Length" msgstr "Longitud del diagnóstico" -msgctxt "field:lims.result_report.template,diagnosis_template:" +msgctxt "field:lims.report.template,diagnosis_template:" msgid "Diagnosis Template" msgstr "Plantilla de Diagnóstico" @@ -267,7 +267,7 @@ msgctxt "help:lims.notebook.repeat_analysis.start,notify_acceptance:" msgid "Notify when analysis is ready" msgstr "Notificar cuando el análisis esté terminado" -msgctxt "help:lims.result_report.template,diagnosis_length:" +msgctxt "help:lims.report.template,diagnosis_length:" msgid "Maximum number of characters in diagnosis" msgstr "Cantidad máxima de caracteres en diagnóstico" diff --git a/lims_diagnosis/results_report.py b/lims_diagnosis/results_report.py index b278da4..a203064 100644 --- a/lims_diagnosis/results_report.py +++ b/lims_diagnosis/results_report.py @@ -110,7 +110,7 @@ class ResultsReportVersionDetail(metaclass=PoolMeta): def _get_fields_from_samples(cls, samples, generate_report_form=None): pool = Pool() Notebook = pool.get('lims.notebook') - ReportTemplate = pool.get('lims.result_report.template') + ReportTemplate = pool.get('lims.report.template') detail_default = super()._get_fields_from_samples(samples, generate_report_form) @@ -476,7 +476,8 @@ class SamplesComparatorLine(ModelSQL, ModelView): result[name] = {} if name == 'result': for l in lines: - result[name][l.id] = l.notebook_line.formated_result + result[name][l.id] = ( + l.notebook_line.get_formated_result()) elif name == 'converted_result': for l in lines: result[name][l.id] = ( @@ -514,7 +515,7 @@ class SamplesComparatorLine(ModelSQL, ModelView): ]) if not notebook_line: return None - return notebook_line[0].formated_result + return notebook_line[0].get_formated_result() class Cron(metaclass=PoolMeta): @@ -533,8 +534,8 @@ class ResultReport(metaclass=PoolMeta): __name__ = 'lims.result_report' @classmethod - def get_context(cls, records, header, data): - report_context = super().get_context(records, header, data) + def get_context(cls, records, data): + report_context = super().get_context(records, data) report_context['state_image'] = cls.get_state_image return report_context diff --git a/lims_diagnosis/view/template_form.xml b/lims_diagnosis/view/result_template_form.xml similarity index 79% rename from lims_diagnosis/view/template_form.xml rename to lims_diagnosis/view/result_template_form.xml index b9ebe14..4a45c9d 100644 --- a/lims_diagnosis/view/template_form.xml +++ b/lims_diagnosis/view/result_template_form.xml @@ -1,6 +1,6 @@ - + diff --git a/lims_report_html/view/create_sample_start_form.xml b/lims_report_html/view/create_sample_start_form.xml index c3dd91f..1b36419 100644 --- a/lims_report_html/view/create_sample_start_form.xml +++ b/lims_report_html/view/create_sample_start_form.xml @@ -4,7 +4,8 @@ expr="/form/notebook/page[@id='report']/separator[@id='report_comments']" position="before">