From 2cc68c75ed7971d34c0b56b1131e1679af16f3de Mon Sep 17 00:00:00 2001 From: oihane Date: Thu, 24 Sep 2015 12:34:24 +0200 Subject: [PATCH] [IMP] added button to fix #255 --- .../models/report_xml.py | 18 ++++++++++++++++++ .../views/report_xml_view.xml | 8 +++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/base_report_auto_create_qweb/models/report_xml.py b/base_report_auto_create_qweb/models/report_xml.py index 6c719f34d..02c12114d 100644 --- a/base_report_auto_create_qweb/models/report_xml.py +++ b/base_report_auto_create_qweb/models/report_xml.py @@ -9,6 +9,12 @@ from openerp import models, api, exceptions, _ class IrActionsReport(models.Model): _inherit = 'ir.actions.report.xml' + def _format_template_name(self, text): + from unidecode import unidecode + text = unidecode(unicode(text)) + text.lower() + return text.encode('iso-8859-1') + def _prepare_qweb_view_data(self, qweb_name, arch): return { 'name': qweb_name, @@ -45,6 +51,8 @@ class IrActionsReport(models.Model): @api.model def create(self, values): + values['report_name'] = self._format_template_name( + values.get('report_name', '')) if not self.env.context.get('enable_duplication', False): return super(IrActionsReport, self).create(values) if (values.get('report_type') in ['qweb-pdf', 'qweb-html'] and @@ -97,3 +105,13 @@ class IrActionsReport(models.Model): self.with_context( report_views=report_views.ids, suffix=suffix.lower())).copy(default=default) + + @api.multi + def button_create_qweb(self): + self.ensure_one() + module = self.report_name.split('.')[0] + report_name = self.report_name.split('.')[1] + arch = ('\n' + '\n' % report_name) + self._create_qweb(self.name, report_name, module, self.model, arch) + self.associated_view() diff --git a/base_report_auto_create_qweb/views/report_xml_view.xml b/base_report_auto_create_qweb/views/report_xml_view.xml index e558770af..865b85b19 100644 --- a/base_report_auto_create_qweb/views/report_xml_view.xml +++ b/base_report_auto_create_qweb/views/report_xml_view.xml @@ -5,7 +5,7 @@ ir.actions.report.xml.form ir.actions.report.xml - +
@@ -13,7 +13,13 @@ string="Duplicate Report" class="oe_highlight" type="action"/>
+
+