lims_report_html: report template: add default comparison range

This commit is contained in:
Adrián Bernardi 2021-06-07 10:15:50 -03:00
parent c108ee498e
commit 9973b5748e
6 changed files with 28 additions and 1 deletions

View File

@ -62,6 +62,8 @@ class ReportTemplate(ModelSQL, ModelView):
('portrait', 'Portrait'),
('landscape','Landscape'),
],'Page orientation',sort=False)
resultrange_origin = fields.Many2One('lims.range.type', 'Comparison range',
domain=[('use', '=', 'result_range')])
@staticmethod
def default_type():

View File

@ -54,6 +54,10 @@ msgctxt "field:lims.result_report.template,report:"
msgid "Report"
msgstr "Informe"
msgctxt "field:lims.result_report.template,resultrange_origin:"
msgid "Comparison range"
msgstr "Rango de comparación"
msgctxt "field:lims.result_report.template,sections:"
msgid "Sections"
msgstr "Secciones"

View File

@ -86,8 +86,11 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
return self.template and self.template.type or None
@fields.depends('template', '_parent_template.trend_charts',
'_parent_template.sections', 'sections')
'_parent_template.sections', 'sections', 'resultrange_origin')
def on_change_template(self):
if (self.template and self.template.resultrange_origin and
not self.resultrange_origin):
self.resultrange_origin = self.template.resultrange_origin.id
if self.template and self.template.trend_charts:
self.trend_charts = [{
'chart': c.chart.id,
@ -130,6 +133,9 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
result_template = cls._get_result_template_from_sample(notebook)
if result_template:
detail_default['template'] = result_template.id
if result_template.resultrange_origin:
detail_default['resultrange_origin'] = (
result_template.resultrange_origin.id)
if result_template.trend_charts:
detail_default['trend_charts'] = [('create', [{
'chart': c.chart.id,

View File

@ -14,6 +14,12 @@ class Sample(metaclass=PoolMeta):
resultrange_origin = fields.Many2One('lims.range.type', 'Comparison range',
domain=[('use', '=', 'result_range')])
@fields.depends('result_template')
def on_change_result_template(self):
if self.result_template and self.result_template.resultrange_origin:
self.resultrange_origin = (
self.result_template.resultrange_origin.id)
class CreateSampleStart(metaclass=PoolMeta):
__name__ = 'lims.create_sample.start'
@ -23,6 +29,12 @@ class CreateSampleStart(metaclass=PoolMeta):
resultrange_origin = fields.Many2One('lims.range.type', 'Comparison range',
domain=[('use', '=', 'result_range')])
@fields.depends('result_template')
def on_change_result_template(self):
if self.result_template and self.result_template.resultrange_origin:
self.resultrange_origin = (
self.result_template.resultrange_origin.id)
class CreateSample(metaclass=PoolMeta):
__name__ = 'lims.create_sample'

View File

@ -6,6 +6,8 @@
<field name="type"/>
<label name="report"/>
<field name="report"/>
<label name="resultrange_origin"/>
<field name="resultrange_origin"/>
<label name="page_orientation"/>
<field name="page_orientation"/>
<notebook>

View File

@ -3,4 +3,5 @@
<field name="name" expand="2"/>
<field name="type"/>
<field name="report"/>
<field name="resultrange_origin"/>
</tree>