From dd5e769e89c15ebe5b485f09bb10f1df53c3f0dd Mon Sep 17 00:00:00 2001 From: oihane Date: Fri, 17 Apr 2015 10:01:18 +0200 Subject: [PATCH] [MOD] Module renamed to Added Known Issues to Readme file --- base_report_auto_create_qweb/README.rst | 20 +++++++++ base_report_auto_create_qweb/__init__.py | 6 +++ base_report_auto_create_qweb/__openerp__.py | 39 +++++++++++++++++ .../models/__init__.py | 6 +++ .../models/report_xml.py | 43 +++++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 base_report_auto_create_qweb/README.rst create mode 100644 base_report_auto_create_qweb/__init__.py create mode 100644 base_report_auto_create_qweb/__openerp__.py create mode 100644 base_report_auto_create_qweb/models/__init__.py create mode 100644 base_report_auto_create_qweb/models/report_xml.py diff --git a/base_report_auto_create_qweb/README.rst b/base_report_auto_create_qweb/README.rst new file mode 100644 index 000000000..7ad0bb818 --- /dev/null +++ b/base_report_auto_create_qweb/README.rst @@ -0,0 +1,20 @@ +Report Management +================= + +When creating a report in Settings > Technical > Actions > Reports or +Settings > Technical > Reports > Reports it will create an empty Qweb template +and the required linking info so that the user does not need to know how to do +all the links. + +Known issues / Roadmap +====================== +* When copying, duplicate all the required objects + +Credits +======= + +Contributors +------------ +* Oihane Crucelaegui +* Pedro M. Baeza +* Ana Juaristi diff --git a/base_report_auto_create_qweb/__init__.py b/base_report_auto_create_qweb/__init__.py new file mode 100644 index 000000000..054c8853d --- /dev/null +++ b/base_report_auto_create_qweb/__init__.py @@ -0,0 +1,6 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import models diff --git a/base_report_auto_create_qweb/__openerp__.py b/base_report_auto_create_qweb/__openerp__.py new file mode 100644 index 000000000..a9fb6f8b5 --- /dev/null +++ b/base_report_auto_create_qweb/__openerp__.py @@ -0,0 +1,39 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## + +{ + "name": "Report Management", + "version": "1.0", + "depends": [ + "base", + "report", + ], + "author": "OdooMRP team, " + "AvanzOSC, " + "Serv. Tecnol. Avanzados - Pedro M. Baeza", + "website": "http://www.odoomrp.com", + "contributors": [ + "Oihane Crucelaegui ", + "Pedro M. Baeza ", + "Ana Juaristi ", + ], + "category": "Tools", + "summary": "", + "data": [], + "installable": True, +} diff --git a/base_report_auto_create_qweb/models/__init__.py b/base_report_auto_create_qweb/models/__init__.py new file mode 100644 index 000000000..40a047607 --- /dev/null +++ b/base_report_auto_create_qweb/models/__init__.py @@ -0,0 +1,6 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import report_xml diff --git a/base_report_auto_create_qweb/models/report_xml.py b/base_report_auto_create_qweb/models/report_xml.py new file mode 100644 index 000000000..602e95212 --- /dev/null +++ b/base_report_auto_create_qweb/models/report_xml.py @@ -0,0 +1,43 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from openerp import models, api, exceptions, _ + + +class IrActionsReport(models.Model): + _inherit = 'ir.actions.report.xml' + + @api.model + def create(self, values): + if (values.get('report_type') in ['qweb-pdf', 'qweb-html'] and + values.get('report_name') and + values['report_name'].find('.') == -1): + raise exceptions.Warning( + _("Template Name must contain at least a dot in it's name")) + report_xml = super(IrActionsReport, self).create(values) + if values.get('report_type') in ['qweb-pdf', 'qweb-html']: + qweb_view_data = { + 'name': values['report_name'].split('.')[1], + 'mode': 'primary', + 'type': 'qweb', + 'arch': '\n' + '\n' % values['report_name'], + } + qweb_view = self.env['ir.ui.view'].create(qweb_view_data) + model_data_data = { + 'module': values['report_name'].split('.')[0], + 'name': values['report_name'].split('.')[1], + 'res_id': qweb_view.id, + 'model': 'ir.ui.view', + } + self.env['ir.model.data'].create(model_data_data) + value_view_data = { + 'name': values['name'], + 'model': values['model'], + 'key2': 'client_print_multi', + 'value_unpickle': 'ir.actions.report.xml,%s' % report_xml.id, + } + self.env['ir.values'].create(value_view_data) + return report_xml