From c99ac07f21dcc9d84a3cf68fc43f7901d2b1469e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Bernardi?= Date: Mon, 17 Jan 2022 10:51:03 -0300 Subject: [PATCH] lims, lims_diagnosis, lims_industry, lims_quality_control: notebook line: new field to show formated result --- lims/locale/es.po | 8 ++++++++ lims/notebook.py | 6 +++++- lims/results_report.py | 2 +- lims/view/notebook_line_all_list.xml | 1 + lims/view/notebook_line_list.xml | 1 + lims_diagnosis/results_report.py | 5 ++--- lims_industry/results_report.py | 2 +- lims_quality_control/lims.py | 2 +- 8 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lims/locale/es.po b/lims/locale/es.po index 33ef462..2293941 100644 --- a/lims/locale/es.po +++ b/lims/locale/es.po @@ -2789,6 +2789,10 @@ msgctxt "field:lims.notebook.line,final_unit:" msgid "Final unit" msgstr "Unidad final" +msgctxt "field:lims.notebook.line,formated_result:" +msgid "Result to report" +msgstr "Resultado a informar" + msgctxt "field:lims.notebook.line,fraction:" msgid "Fraction" msgstr "Fracción" @@ -3097,6 +3101,10 @@ msgctxt "field:lims.notebook.line.all_fields,final_unit:" msgid "Final unit" msgstr "Unidad final" +msgctxt "field:lims.notebook.all_fields,formated_result:" +msgid "Result to report" +msgstr "Resultado a informar" + msgctxt "field:lims.notebook.line.all_fields,fraction:" msgid "Fraction" msgstr "Fracción" diff --git a/lims/notebook.py b/lims/notebook.py index 8dcf98a..3e3537e 100644 --- a/lims/notebook.py +++ b/lims/notebook.py @@ -883,6 +883,8 @@ class NotebookLine(ModelSQL, ModelView): states=_states, depends=_depends) converted_result = fields.Char('Converted result', states=_states, depends=_depends) + formated_result = fields.Function(fields.Char('Result to report'), + 'get_formated_result') detection_limit = fields.Char('Detection limit', states=_states, depends=_depends) quantification_limit = fields.Char('Quantification limit', @@ -1582,7 +1584,7 @@ class NotebookLine(ModelSQL, ModelView): return self.planification.comments return '' - def get_formated_result(self): + def get_formated_result(self, name=None): res = '' result_modifier = self.result_modifier if self.literal_result: @@ -1726,6 +1728,8 @@ class NotebookLineAllFields(ModelSQL, ModelView): 'converted_result_modifier') result = fields.Char('Result', readonly=True) converted_result = fields.Char('Converted result', readonly=True) + formated_result = fields.Function(fields.Char('Result to report'), + 'get_line_field') detection_limit = fields.Char('Detection limit', readonly=True) quantification_limit = fields.Char('Quantification limit', readonly=True) lower_limit = fields.Char('Lower limit allowed', readonly=True) diff --git a/lims/results_report.py b/lims/results_report.py index 3694c65..1e3403a 100644 --- a/lims/results_report.py +++ b/lims/results_report.py @@ -1821,7 +1821,7 @@ class ResultsReportVersionDetailLine(ModelSQL, ModelView): result = {} for d in details: result[d.id] = (d.notebook_line and - d.notebook_line.get_formated_result() or None) + d.notebook_line.formated_result or None) return result @classmethod diff --git a/lims/view/notebook_line_all_list.xml b/lims/view/notebook_line_all_list.xml index 6775fcb..a14641f 100644 --- a/lims/view/notebook_line_all_list.xml +++ b/lims/view/notebook_line_all_list.xml @@ -28,6 +28,7 @@ + diff --git a/lims/view/notebook_line_list.xml b/lims/view/notebook_line_list.xml index 377571d..fbe029a 100644 --- a/lims/view/notebook_line_list.xml +++ b/lims/view/notebook_line_list.xml @@ -24,6 +24,7 @@ + diff --git a/lims_diagnosis/results_report.py b/lims_diagnosis/results_report.py index a889f9e..544fdf7 100644 --- a/lims_diagnosis/results_report.py +++ b/lims_diagnosis/results_report.py @@ -423,8 +423,7 @@ class SamplesComparatorLine(ModelSQL, ModelView): result[name] = {} if name == 'result': for l in lines: - result[name][l.id] = ( - l.notebook_line.get_formated_result()) + result[name][l.id] = l.notebook_line.formated_result elif name == 'converted_result': for l in lines: result[name][l.id] = ( @@ -462,7 +461,7 @@ class SamplesComparatorLine(ModelSQL, ModelView): ]) if not notebook_line: return None - return notebook_line[0].get_formated_result() + return notebook_line[0].formated_result class Cron(metaclass=PoolMeta): diff --git a/lims_industry/results_report.py b/lims_industry/results_report.py index 550ff06..4e22391 100644 --- a/lims_industry/results_report.py +++ b/lims_industry/results_report.py @@ -838,7 +838,7 @@ class ResultsReportVersionDetailLine(metaclass=PoolMeta): ]) if not precedent_line: return '' - return precedent_line[0].get_formated_result() + return precedent_line[0].formated_result class OpenResultsDetailPrecedent(Wizard): diff --git a/lims_quality_control/lims.py b/lims_quality_control/lims.py index 210b4d8..61c2aa7 100644 --- a/lims_quality_control/lims.py +++ b/lims_quality_control/lims.py @@ -262,7 +262,7 @@ class NotebookLine(metaclass=PoolMeta): def get_test_result(cls, lines, name): result = {} for line in lines: - result[line.id] = line.get_formated_result() + result[line.id] = line.formated_result return result @classmethod