diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-09-13 12:05:33 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-09-13 12:05:33 +0700 |
| commit | 8f3d096dbae18bacd95796d03b17d4d94a806c85 (patch) | |
| tree | ae90032724dabe417b907db43145639e6df9565f /jasper_reports/wizard | |
| parent | 0d87fec0c4c6fb573b1a09076f6d50844d8d0a80 (diff) | |
jasper report integration
Diffstat (limited to 'jasper_reports/wizard')
| -rwxr-xr-x | jasper_reports/wizard/__init__.py | 30 | ||||
| -rwxr-xr-x | jasper_reports/wizard/jasper_create_data_template.py | 61 | ||||
| -rwxr-xr-x | jasper_reports/wizard/jasper_create_data_template.xml | 33 |
3 files changed, 124 insertions, 0 deletions
diff --git a/jasper_reports/wizard/__init__.py b/jasper_reports/wizard/__init__.py new file mode 100755 index 0000000..ec436fd --- /dev/null +++ b/jasper_reports/wizard/__init__.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2011-Today Serpent Consulting Services Pvt. Ltd. +# (<http://www.serpentcs.com>) +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +from . import jasper_create_data_template diff --git a/jasper_reports/wizard/jasper_create_data_template.py b/jasper_reports/wizard/jasper_create_data_template.py new file mode 100755 index 0000000..e80e5c6 --- /dev/null +++ b/jasper_reports/wizard/jasper_create_data_template.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2012 Omar Castiñeira Saavedra <omar@pexego.es> +# Pexego Sistemas Informáticos http://www.pexego.es +# Copyright (C) 2013 Tadeus Prastowo <tadeus.prastowo@infi-nity.com> +# Vikasa Infinity Anugrah <http://www.infi-nity.com> +# Copyright (C) 2019-Today Serpent Consulting Services Pvt. Ltd. +# (<http://www.serpentcs.com>) +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import base64 +from odoo import fields, models + + +class CreateDataTemplate(models.TransientModel): + + _name = 'jasper.create.data.template' + _description = 'Create Data Template' + + model_id = fields.Many2one('ir.model', required=True) + depth = fields.Integer(required=True, default=1) + filename = fields.Char('File Name', size=32) + data = fields.Binary('XML') + + def action_create_xml(self): + report_obj = self.env['ir.actions.report'] + for data_template in self: + xml = report_obj.create_xml( + data_template.model_id.model, data_template.depth) + base64_str = base64.encodestring( + ('%s' % (xml)).encode()).decode().replace('\n', '') + data_template.write({ + 'data': base64_str, + 'filename': str(data_template.model_id.name) + '_template.xml'}) + [action] = self.env.ref( + 'jasper_reports.action_jasper_create_date_template').read() + action.update({'res_id': data_template.id}) + return action diff --git a/jasper_reports/wizard/jasper_create_data_template.xml b/jasper_reports/wizard/jasper_create_data_template.xml new file mode 100755 index 0000000..0ed7629 --- /dev/null +++ b/jasper_reports/wizard/jasper_create_data_template.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + + <record id="view_pos_box_out" model="ir.ui.view"> + <field name="name">Create Data Template</field> + <field name="model">jasper.create.data.template</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form name="Create Data Template"> + <group colspan="2"> + <field name="model_id"/> + <field name="depth"/> + <field name="data" filename="filename" readonly="1"/> + <field name="filename" invisible="1"/> + </group> + <footer> + <button name="action_create_xml" string="Create" type="object" title="Create" role="button" class="oe_highlight"> + <i class="fa fa-check" aria-label="Create" aria-hidden="true"/> + </button> + <button special="cancel" string="Close" class="oe_highlight"/> + </footer> + </form> + </field> + </record> + + <record id="action_jasper_create_date_template" model="ir.actions.act_window"> + <field name="name">Create Data Template</field> + <field name="res_model">jasper.create.data.template</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + +</odoo> |
