From c83e9b51e319104dca3fb36f2e295f8386d06c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 27 Sep 2017 18:50:07 +0200 Subject: [PATCH] Allow to use report name or instance in get_email issue6774 review38731002 --- trytond/report/report.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/trytond/report/report.py b/trytond/report/report.py index 5fedbf899e..bec5022ca0 100644 --- a/trytond/report/report.py +++ b/trytond/report/report.py @@ -338,15 +338,25 @@ class Report(URLMixin, PoolBase): def get_email(report, record, languages): "Return email.mime and title from the report execution" pool = Pool() - Report = pool.get(report.report_name, type='report') + ActionReport = pool.get('ir.action.report') + report_id = None + if isinstance(report, Report): + Report_ = report + else: + if isinstance(report, ActionReport): + report_name = report.report_name + report_id = report.id + else: + report_name = report + Report_ = pool.get(report_name, type='report') converter = None msg = MIMEMultipart('alternative') msg.add_header('Content-Language', ', '.join(l.code for l in languages)) for language in languages: with Transaction().set_context(language=language.code): - ext, content, _, title = Report.execute( + ext, content, _, title = Report_.execute( [record.id], { - 'action_id': report.id, + 'action_id': report_id, 'language': language, }) if ext == 'html' and html2text: