From 6b0eac601ae8f6e48f78f8586e4da09c66a165b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Thu, 18 Dec 2014 11:36:40 +0100 Subject: [PATCH] Use data's action_id to find report to use issue4411 review10741002 --- CHANGELOG | 1 + trytond/ir/action.py | 7 +++---- trytond/report/report.py | 17 +++++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1e18bef2bf..9f03745c79 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Use action_id to find report to use * Allow custom StateView without Model * Remove Pool.object_name_list * Add translated descriptor for Dict field diff --git a/trytond/ir/action.py b/trytond/ir/action.py index 027de8e7ed..d5c9477a89 100644 --- a/trytond/ir/action.py +++ b/trytond/ir/action.py @@ -477,10 +477,6 @@ class ActionReport(ActionMixin, ModelSQL, ModelView): @classmethod def __setup__(cls): super(ActionReport, cls).__setup__() - cls._sql_constraints += [ - ('report_name_module_uniq', 'UNIQUE(report_name, module)', - 'The internal name must be unique by module!'), - ] cls._error_messages.update({ 'invalid_email': 'Invalid email definition on report "%s".', }) @@ -544,6 +540,9 @@ class ActionReport(ActionMixin, ModelSQL, ModelView): where=action_report.id == report_id)) table.drop_column('report_content_data') + # Migration from 3.4 remove report_name_module_uniq constraint + table.drop_constraint('report_name_module_uniq') + @staticmethod def default_type(): return 'ir.action.report' diff --git a/trytond/report/report.py b/trytond/report/report.py index dfbe2f9098..0d6db695c2 100644 --- a/trytond/report/report.py +++ b/trytond/report/report.py @@ -130,13 +130,18 @@ class Report(URLMixin, PoolBase): ''' pool = Pool() ActionReport = pool.get('ir.action.report') - action_reports = ActionReport.search([ - ('report_name', '=', cls.__name__) - ]) - if not action_reports: - raise Exception('Error', 'Report (%s) not find!' % cls.__name__) cls.check_access() - action_report = action_reports[0] + + action_id = data.get('action_id') + if action_id is None: + action_reports = ActionReport.search([ + ('report_name', '=', cls.__name__) + ]) + assert action_reports, '%s not found' % cls + action_report = action_reports[0] + else: + action_report = ActionReport(action_id) + records = None model = action_report.model or data.get('model') if model: