diff --git a/lims_report_html/__init__.py b/lims_report_html/__init__.py
index 55ee268..4e4a6c4 100644
--- a/lims_report_html/__init__.py
+++ b/lims_report_html/__init__.py
@@ -6,6 +6,8 @@ from trytond.pool import Pool
from . import action
from . import html_template
from . import configuration
+from . import laboratory
+from . import party
from . import sample
from . import analysis
from . import results_report
@@ -20,6 +22,8 @@ def register():
html_template.ReportTemplateSection,
html_template.ReportTemplateTrendChart,
configuration.Configuration,
+ laboratory.Laboratory,
+ party.Party,
sample.Fraction,
sample.Sample,
sample.CreateSampleStart,
diff --git a/lims_report_html/laboratory.py b/lims_report_html/laboratory.py
new file mode 100644
index 0000000..ea0339e
--- /dev/null
+++ b/lims_report_html/laboratory.py
@@ -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'])])
diff --git a/lims_report_html/laboratory.xml b/lims_report_html/laboratory.xml
new file mode 100644
index 0000000..659b99a
--- /dev/null
+++ b/lims_report_html/laboratory.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ lims.laboratory
+
+ laboratory_form
+
+
+
+
diff --git a/lims_report_html/locale/es.po b/lims_report_html/locale/es.po
index 9623aec..4cfa363 100644
--- a/lims_report_html/locale/es.po
+++ b/lims_report_html/locale/es.po
@@ -22,6 +22,10 @@ msgctxt "field:lims.fraction,result_template:"
msgid "Report Template"
msgstr "Plantilla de Informe"
+msgctxt "field:lims.laboratory,result_template:"
+msgid "Report Template"
+msgstr "Plantilla de Informe"
+
msgctxt "field:lims.notebook,result_template:"
msgid "Report Template"
msgstr "Plantilla de Informe"
@@ -226,6 +230,10 @@ msgctxt "field:lims.sample,resultrange_origin:"
msgid "Comparison range"
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"
msgid "Results Report Templates"
msgstr "Plantillas de Informe de resultados"
diff --git a/lims_report_html/party.py b/lims_report_html/party.py
new file mode 100644
index 0000000..9d1e028
--- /dev/null
+++ b/lims_report_html/party.py
@@ -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'])])
diff --git a/lims_report_html/party.xml b/lims_report_html/party.xml
new file mode 100644
index 0000000..3bdda1f
--- /dev/null
+++ b/lims_report_html/party.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ party.party
+
+ party_party_form
+
+
+
+
diff --git a/lims_report_html/results_report.py b/lims_report_html/results_report.py
index 6fc7634..4610cdd 100644
--- a/lims_report_html/results_report.py
+++ b/lims_report_html/results_report.py
@@ -176,6 +176,7 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
def _get_result_template_from_sample(cls, notebook):
pool = Pool()
Service = pool.get('lims.service')
+ Laboratory = pool.get('lims.laboratory')
Configuration = pool.get('lims.configuration')
result_template = notebook.fraction.sample.result_template
@@ -197,6 +198,13 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
if not ok:
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:
config_ = Configuration(1)
result_template = config_.result_template
diff --git a/lims_report_html/sample.py b/lims_report_html/sample.py
index 4591692..2a60215 100644
--- a/lims_report_html/sample.py
+++ b/lims_report_html/sample.py
@@ -62,6 +62,21 @@ class CreateSampleStart(metaclass=PoolMeta):
class CreateSample(metaclass=PoolMeta):
__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):
samples_defaults = super()._get_samples_defaults(entry_id)
diff --git a/lims_report_html/tryton.cfg b/lims_report_html/tryton.cfg
index e5034cb..cdd274e 100644
--- a/lims_report_html/tryton.cfg
+++ b/lims_report_html/tryton.cfg
@@ -5,6 +5,8 @@ depends:
xml:
html_template.xml
configuration.xml
+ laboratory.xml
+ party.xml
sample.xml
analysis.xml
results_report.xml
diff --git a/lims_report_html/view/laboratory_form.xml b/lims_report_html/view/laboratory_form.xml
new file mode 100644
index 0000000..439fc96
--- /dev/null
+++ b/lims_report_html/view/laboratory_form.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/lims_report_html/view/party_party_form.xml b/lims_report_html/view/party_party_form.xml
new file mode 100644
index 0000000..61e8c62
--- /dev/null
+++ b/lims_report_html/view/party_party_form.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+