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">