lims_report_html: add default report template in Party and Laboratory
This commit is contained in:
parent
14c6fa258e
commit
54a62034a4
|
@ -6,6 +6,8 @@ from trytond.pool import Pool
|
||||||
from . import action
|
from . import action
|
||||||
from . import html_template
|
from . import html_template
|
||||||
from . import configuration
|
from . import configuration
|
||||||
|
from . import laboratory
|
||||||
|
from . import party
|
||||||
from . import sample
|
from . import sample
|
||||||
from . import analysis
|
from . import analysis
|
||||||
from . import results_report
|
from . import results_report
|
||||||
|
@ -20,6 +22,8 @@ def register():
|
||||||
html_template.ReportTemplateSection,
|
html_template.ReportTemplateSection,
|
||||||
html_template.ReportTemplateTrendChart,
|
html_template.ReportTemplateTrendChart,
|
||||||
configuration.Configuration,
|
configuration.Configuration,
|
||||||
|
laboratory.Laboratory,
|
||||||
|
party.Party,
|
||||||
sample.Fraction,
|
sample.Fraction,
|
||||||
sample.Sample,
|
sample.Sample,
|
||||||
sample.CreateSampleStart,
|
sample.CreateSampleStart,
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
class Laboratory(metaclass=PoolMeta):
|
||||||
|
__name__ = 'lims.laboratory'
|
||||||
|
|
||||||
|
result_template = fields.Many2One('lims.result_report.template',
|
||||||
|
'Report Template', domain=[('type', 'in', [None, 'base'])])
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<!-- Laboratory -->
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="laboratory_view_form">
|
||||||
|
<field name="model">lims.laboratory</field>
|
||||||
|
<field name="inherit" ref="lims.lims_laboratory_view_form"/>
|
||||||
|
<field name="name">laboratory_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</tryton>
|
|
@ -22,6 +22,10 @@ msgctxt "field:lims.fraction,result_template:"
|
||||||
msgid "Report Template"
|
msgid "Report Template"
|
||||||
msgstr "Plantilla de Informe"
|
msgstr "Plantilla de Informe"
|
||||||
|
|
||||||
|
msgctxt "field:lims.laboratory,result_template:"
|
||||||
|
msgid "Report Template"
|
||||||
|
msgstr "Plantilla de Informe"
|
||||||
|
|
||||||
msgctxt "field:lims.notebook,result_template:"
|
msgctxt "field:lims.notebook,result_template:"
|
||||||
msgid "Report Template"
|
msgid "Report Template"
|
||||||
msgstr "Plantilla de Informe"
|
msgstr "Plantilla de Informe"
|
||||||
|
@ -226,6 +230,10 @@ msgctxt "field:lims.sample,resultrange_origin:"
|
||||||
msgid "Comparison range"
|
msgid "Comparison range"
|
||||||
msgstr "Rango de comparación"
|
msgstr "Rango de comparación"
|
||||||
|
|
||||||
|
msgctxt "field:party.party,result_template:"
|
||||||
|
msgid "Report Template"
|
||||||
|
msgstr "Plantilla de Informe"
|
||||||
|
|
||||||
msgctxt "model:ir.action,name:act_html_template_list"
|
msgctxt "model:ir.action,name:act_html_template_list"
|
||||||
msgid "Results Report Templates"
|
msgid "Results Report Templates"
|
||||||
msgstr "Plantillas de Informe de resultados"
|
msgstr "Plantillas de Informe de resultados"
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
class Party(metaclass=PoolMeta):
|
||||||
|
__name__ = 'party.party'
|
||||||
|
|
||||||
|
result_template = fields.Many2One('lims.result_report.template',
|
||||||
|
'Report Template', domain=[('type', 'in', [None, 'base'])])
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<!-- Party -->
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="party_view_form">
|
||||||
|
<field name="model">party.party</field>
|
||||||
|
<field name="inherit" ref="party.party_view_form"/>
|
||||||
|
<field name="name">party_party_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</tryton>
|
|
@ -176,6 +176,7 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
|
||||||
def _get_result_template_from_sample(cls, notebook):
|
def _get_result_template_from_sample(cls, notebook):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Service = pool.get('lims.service')
|
Service = pool.get('lims.service')
|
||||||
|
Laboratory = pool.get('lims.laboratory')
|
||||||
Configuration = pool.get('lims.configuration')
|
Configuration = pool.get('lims.configuration')
|
||||||
|
|
||||||
result_template = notebook.fraction.sample.result_template
|
result_template = notebook.fraction.sample.result_template
|
||||||
|
@ -197,6 +198,13 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
|
||||||
if not ok:
|
if not ok:
|
||||||
result_template = None
|
result_template = None
|
||||||
|
|
||||||
|
if not result_template:
|
||||||
|
laboratory_id = Transaction().context.get(
|
||||||
|
'samples_pending_reporting_laboratory', None)
|
||||||
|
if laboratory_id:
|
||||||
|
laboratory = Laboratory(laboratory_id)
|
||||||
|
result_template = laboratory.result_template
|
||||||
|
|
||||||
if not result_template:
|
if not result_template:
|
||||||
config_ = Configuration(1)
|
config_ = Configuration(1)
|
||||||
result_template = config_.result_template
|
result_template = config_.result_template
|
||||||
|
|
|
@ -62,6 +62,21 @@ class CreateSampleStart(metaclass=PoolMeta):
|
||||||
class CreateSample(metaclass=PoolMeta):
|
class CreateSample(metaclass=PoolMeta):
|
||||||
__name__ = 'lims.create_sample'
|
__name__ = 'lims.create_sample'
|
||||||
|
|
||||||
|
def default_start(self, fields):
|
||||||
|
Party = Pool().get('party.party')
|
||||||
|
|
||||||
|
defaults = super().default_start(fields)
|
||||||
|
|
||||||
|
party_id = defaults['party']
|
||||||
|
if party_id:
|
||||||
|
party = Party(party_id)
|
||||||
|
if party.result_template:
|
||||||
|
defaults['result_template'] = party.result_template.id
|
||||||
|
if party.result_template.resultrange_origin:
|
||||||
|
defaults['resultrange_origin'] = (
|
||||||
|
party.result_template.resultrange_origin.id)
|
||||||
|
return defaults
|
||||||
|
|
||||||
def _get_samples_defaults(self, entry_id):
|
def _get_samples_defaults(self, entry_id):
|
||||||
samples_defaults = super()._get_samples_defaults(entry_id)
|
samples_defaults = super()._get_samples_defaults(entry_id)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ depends:
|
||||||
xml:
|
xml:
|
||||||
html_template.xml
|
html_template.xml
|
||||||
configuration.xml
|
configuration.xml
|
||||||
|
laboratory.xml
|
||||||
|
party.xml
|
||||||
sample.xml
|
sample.xml
|
||||||
analysis.xml
|
analysis.xml
|
||||||
results_report.xml
|
results_report.xml
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<data>
|
||||||
|
<xpath expr="/form/field[@name='headquarters']" position="after">
|
||||||
|
<label name="result_template"/>
|
||||||
|
<field name="result_template"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<data>
|
||||||
|
<xpath
|
||||||
|
expr="/form/notebook/page[@id='lims']/field[@name='report_language']"
|
||||||
|
position="after">
|
||||||
|
<label name="result_template"/>
|
||||||
|
<field name="result_template"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
Loading…
Reference in New Issue