diff --git a/lims_report_html/analysis.py b/lims_report_html/analysis.py index 3ec5dca..37d7fcd 100644 --- a/lims_report_html/analysis.py +++ b/lims_report_html/analysis.py @@ -14,6 +14,8 @@ class Analysis(metaclass=PoolMeta): 'Report Template', domain=[ ('report_name', '=', 'lims.result_report'), ('type', 'in', [None, 'base']), + ['OR', ('active', '=', True), + ('id', '=', Eval('result_template'))], ], states={'readonly': Eval('type') != 'group'}, depends=['type']) diff --git a/lims_report_html/configuration.py b/lims_report_html/configuration.py index 69c1066..f00ea36 100644 --- a/lims_report_html/configuration.py +++ b/lims_report_html/configuration.py @@ -4,6 +4,7 @@ from trytond.model import fields from trytond.pool import PoolMeta +from trytond.pyson import Eval class Configuration(metaclass=PoolMeta): @@ -13,4 +14,6 @@ class Configuration(metaclass=PoolMeta): 'Default Report Template', domain=[ ('report_name', '=', 'lims.result_report'), ('type', 'in', [None, 'base']), + ['OR', ('active', '=', True), + ('id', '=', Eval('result_template'))], ]) diff --git a/lims_report_html/html_template.py b/lims_report_html/html_template.py index 685134c..9ea08ba 100644 --- a/lims_report_html/html_template.py +++ b/lims_report_html/html_template.py @@ -18,7 +18,7 @@ from babel.support import Translations as BabelTranslations from mimetypes import guess_type as mime_guess_type from sql import Literal -from trytond.model import ModelSQL, ModelView, fields +from trytond.model import ModelSQL, ModelView, DeactivableMixin, fields from trytond.report import Report from trytond.pool import Pool from trytond.pyson import Eval, Bool, Or @@ -31,7 +31,7 @@ from trytond import backend from .generator import PdfGenerator -class ReportTemplate(ModelSQL, ModelView): +class ReportTemplate(DeactivableMixin, ModelSQL, ModelView): 'Report Template' __name__ = 'lims.report.template' @@ -59,12 +59,16 @@ class ReportTemplate(ModelSQL, ModelView): domain=[ ('report_name', '=', Eval('report_name')), ('type', '=', 'header'), + ['OR', ('active', '=', True), + ('id', '=', Eval('header'))], ], depends=['report_name']) footer = fields.Many2One('lims.report.template', 'Footer', domain=[ ('report_name', '=', Eval('report_name')), ('type', '=', 'footer'), + ['OR', ('active', '=', True), + ('id', '=', Eval('footer'))], ], depends=['report_name']) translations = fields.One2Many('lims.report.template.translation', diff --git a/lims_report_html/laboratory.py b/lims_report_html/laboratory.py index 6f01ede..342fb83 100644 --- a/lims_report_html/laboratory.py +++ b/lims_report_html/laboratory.py @@ -4,6 +4,7 @@ from trytond.model import fields from trytond.pool import PoolMeta +from trytond.pyson import Eval class Laboratory(metaclass=PoolMeta): @@ -13,4 +14,6 @@ class Laboratory(metaclass=PoolMeta): 'Report Template', domain=[ ('report_name', '=', 'lims.result_report'), ('type', 'in', [None, 'base']), + ['OR', ('active', '=', True), + ('id', '=', Eval('result_template'))], ]) diff --git a/lims_report_html/party.py b/lims_report_html/party.py index 67acf12..19f911e 100644 --- a/lims_report_html/party.py +++ b/lims_report_html/party.py @@ -4,6 +4,7 @@ from trytond.model import fields from trytond.pool import PoolMeta +from trytond.pyson import Eval class Party(metaclass=PoolMeta): @@ -13,4 +14,6 @@ class Party(metaclass=PoolMeta): 'Report Template', domain=[ ('report_name', '=', 'lims.result_report'), ('type', 'in', [None, 'base']), + ['OR', ('active', '=', True), + ('id', '=', Eval('result_template'))], ]) diff --git a/lims_report_html/results_report.py b/lims_report_html/results_report.py index 7c96321..e018b03 100644 --- a/lims_report_html/results_report.py +++ b/lims_report_html/results_report.py @@ -21,6 +21,8 @@ class ResultsReportVersionDetail(metaclass=PoolMeta): 'Report Template', domain=[ ('report_name', '=', 'lims.result_report'), ('type', 'in', [None, 'base']), + ['OR', ('active', '=', True), + ('id', '=', Eval('template'))], ], states={'readonly': Eval('state') != 'draft'}, depends=['state']) @@ -495,6 +497,8 @@ class GenerateReportStart(metaclass=PoolMeta): 'Report Template', domain=[ ('report_name', '=', 'lims.result_report'), ('type', 'in', [None, 'base']), + ['OR', ('active', '=', True), + ('id', '=', Eval('template'))], ], states={'readonly': Bool(Eval('report'))}, depends=['report']) diff --git a/lims_report_html/sample.py b/lims_report_html/sample.py index cd13cef..93bd346 100644 --- a/lims_report_html/sample.py +++ b/lims_report_html/sample.py @@ -4,6 +4,7 @@ from trytond.model import fields from trytond.pool import Pool, PoolMeta +from trytond.pyson import Eval class Fraction(metaclass=PoolMeta): @@ -36,6 +37,8 @@ class Sample(metaclass=PoolMeta): 'Report Template', domain=[ ('report_name', '=', 'lims.result_report'), ('type', 'in', [None, 'base']), + ['OR', ('active', '=', True), + ('id', '=', Eval('result_template'))], ]) resultrange_origin = fields.Many2One('lims.range.type', 'Comparison range', domain=[('use', '=', 'result_range')]) @@ -54,6 +57,8 @@ class CreateSampleStart(metaclass=PoolMeta): 'Report Template', domain=[ ('report_name', '=', 'lims.result_report'), ('type', 'in', [None, 'base']), + ['OR', ('active', '=', True), + ('id', '=', Eval('result_template'))], ]) resultrange_origin = fields.Many2One('lims.range.type', 'Comparison range', domain=[('use', '=', 'result_range')]) diff --git a/lims_report_html/view/result_template_form.xml b/lims_report_html/view/result_template_form.xml index 9db9dfa..3db991f 100644 --- a/lims_report_html/view/result_template_form.xml +++ b/lims_report_html/view/result_template_form.xml @@ -10,6 +10,8 @@