From 015603c847736bf86d459fb0693c8b9988c1cf24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 13 Dec 2016 18:31:42 +0100 Subject: [PATCH] Hide report path if custom template is set This gives visual hint to the user about customization. issue6064 review25831002 --- trytond/ir/action.py | 13 +++++++++++-- trytond/ir/view/action_report_form.xml | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/trytond/ir/action.py b/trytond/ir/action.py index 8fdb78ff98..93e0ad3876 100644 --- a/trytond/ir/action.py +++ b/trytond/ir/action.py @@ -12,7 +12,7 @@ from sql.aggregate import Count from ..model import ModelView, ModelStorage, ModelSQL, fields from ..tools import file_open from .. import backend -from ..pyson import PYSONDecoder, PYSON +from ..pyson import PYSONDecoder, PYSON, Eval from ..transaction import Transaction from ..pool import Pool from ..cache import Cache @@ -392,8 +392,14 @@ class ActionReport(ActionMixin, ModelSQL, ModelView): _action_name = 'report_name' model = fields.Char('Model') report_name = fields.Char('Internal Name', required=True) - report = fields.Char('Path') + report = fields.Char( + "Path", + states={ + 'invisible': Eval('is_custom', False), + }, + depends=['is_custom']) report_content_custom = fields.Binary('Content') + is_custom = fields.Function(fields.Boolean("Is Custom"), 'get_is_custom') report_content = fields.Function(fields.Binary('Content', filename='report_content_name'), 'get_report_content', setter='set_report_content') @@ -603,6 +609,9 @@ class ActionReport(ActionMixin, ModelSQL, ModelView): else: cls.raise_user_error('invalid_email', (report.rec_name,)) + def get_is_custom(self, name): + return bool(self.report_content_custom) + @classmethod def get_report_content(cls, reports, name): contents = {} diff --git a/trytond/ir/view/action_report_form.xml b/trytond/ir/view/action_report_form.xml index e83b053fac..64e9bf8b56 100644 --- a/trytond/ir/view/action_report_form.xml +++ b/trytond/ir/view/action_report_form.xml @@ -15,10 +15,10 @@ this repository contains the full copyright notices and license terms. -->