lims_report_html/lims_diagnosis: associate report template to analysis group

This commit is contained in:
Adrián Bernardi 2020-10-27 12:35:25 -03:00
parent e3e1d46a3c
commit aacb4ae4e0
9 changed files with 77 additions and 12 deletions

View File

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

View File

@ -1,11 +1,9 @@
<?xml version="1.0"?>
<data>
<xpath expr="/form/notebook/page[@id='times']" position="after">
<page id="diagnosis" string="Diagnosis">
<label name="diagnostician"/>
<field name="diagnostician"/>
<label name="not_block_diagnosis"/>
<field name="not_block_diagnosis"/>
</page>
<xpath expr="/form/notebook/page[@id='report']" position="inside">
<label name="diagnostician"/>
<field name="diagnostician"/>
<label name="not_block_diagnosis"/>
<field name="not_block_diagnosis"/>
</xpath>
</data>

View File

@ -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,

View File

@ -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'])

View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<tryton>
<data>
<!-- Analysis/Set/Group -->
<record model="ir.ui.view" id="analysis_view_form">
<field name="model">lims.analysis</field>
<field name="inherit" ref="lims.lims_analysis_view_form"/>
<field name="name">analysis_form</field>
</record>
</data>
</tryton>

View File

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

View File

@ -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)

View File

@ -5,5 +5,6 @@ depends:
xml:
html_template.xml
sample.xml
analysis.xml
results_report.xml
message.xml

View File

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<data>
<xpath expr="/form/notebook/page[@id='times']" position="after">
<page id="report" string="Report">
<label name="result_template"/>
<field name="result_template"/>
</page>
</xpath>
</data>