[MIG] report_py3o, report_py3o_fusion_server: Migration to 12.0

pull/479/head
Laurent Mignon (ACSONE) 2018-11-26 17:58:30 +01:00 committed by Alexis de Lattre
parent 549ff5f31e
commit 6b55c4ef0d
12 changed files with 17 additions and 26 deletions

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Therp BV <http://therp.nl> # Copyright 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models

View File

@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Therp BV <http://therp.nl> # Copyright 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
'name': 'Py3o Report Engine - Fusion server support', 'name': 'Py3o Report Engine - Fusion server support',
'summary': 'Let the fusion server handle format conversion.', 'summary': 'Let the fusion server handle format conversion.',
'version': '10.0.1.0.0', 'version': '12.0.1.0.0',
'category': 'Reporting', 'category': 'Reporting',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': 'XCG Consulting,' 'author': 'XCG Consulting,'
@ -23,7 +22,7 @@
"demo/py3o_pdf_options.xml", "demo/py3o_pdf_options.xml",
], ],
'data': [ 'data': [
"views/ir_report.xml", "views/ir_actions_report.xml",
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'views/py3o_server.xml', 'views/py3o_server.xml',
'views/py3o_pdf_options.xml', 'views/py3o_pdf_options.xml',

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<odoo> <odoo>
<record id="report_py3o.res_users_report_py3o" model="ir.actions.report.xml"> <record id="report_py3o.res_users_report_py3o" model="ir.actions.report">
<field name="py3o_is_local_fusion" eval="1"/> <field name="py3o_is_local_fusion" eval="1"/>
</record> </record>
</odoo> </odoo>

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Therp BV <http://therp.nl> # Copyright 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import ir_actions_report_xml from . import ir_actions_report
from . import py3o_pdf_options from . import py3o_pdf_options
from . import py3o_report from . import py3o_report
from . import py3o_server from . import py3o_server

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2013 XCG Consulting <http://odoo.consulting> # © 2013 XCG Consulting <http://odoo.consulting>
# © 2017 Therp BV <http://therp.nl> # © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -14,8 +13,8 @@ except ImportError:
logger.debug('Cannot import py3o.formats') logger.debug('Cannot import py3o.formats')
class IrActionsReportXml(models.Model): class IrActionsReport(models.Model):
_inherit = 'ir.actions.report.xml' _inherit = 'ir.actions.report'
@api.multi @api.multi
@api.constrains("py3o_is_local_fusion", "py3o_server_id", "py3o_filetype") @api.constrains("py3o_is_local_fusion", "py3o_server_id", "py3o_filetype")

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Akretion (http://www.akretion.com) # Copyright 2018 Akretion (http://www.akretion.com)
# @author: Alexis de Lattre <alexis.delattre@akretion.com> # @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2013 XCG Consulting <http://odoo.consulting> # © 2013 XCG Consulting <http://odoo.consulting>
# © 2016 ACSONE SA/NV # © 2016 ACSONE SA/NV
# © 2017 Therp BV <http://therp.nl> # © 2017 Therp BV <http://therp.nl>
@ -12,7 +11,7 @@ from datetime import datetime
from contextlib import closing from contextlib import closing
from openerp import _, api, models from openerp import _, api, models
from openerp.exceptions import UserError from openerp.exceptions import UserError
from StringIO import StringIO from io import BytesIO
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -27,15 +26,15 @@ class Py3oReport(models.TransientModel):
_inherit = 'py3o.report' _inherit = 'py3o.report'
@api.multi @api.multi
def _create_single_report(self, model_instance, data, save_in_attachment): def _create_single_report(self, model_instance, data):
""" This function to generate our py3o report """ This function to generate our py3o report
""" """
self.ensure_one() self.ensure_one()
report_xml = self.ir_actions_report_xml_id report_xml = self.ir_actions_report_id
filetype = report_xml.py3o_filetype filetype = report_xml.py3o_filetype
if not report_xml.py3o_server_id: if not report_xml.py3o_server_id:
return super(Py3oReport, self)._create_single_report( return super(Py3oReport, self)._create_single_report(
model_instance, data, save_in_attachment, model_instance, data,
) )
elif report_xml.py3o_is_local_fusion: elif report_xml.py3o_is_local_fusion:
result_path = super( result_path = super(
@ -43,9 +42,9 @@ class Py3oReport(models.TransientModel):
report_py3o_skip_conversion=True, report_py3o_skip_conversion=True,
) )
)._create_single_report( )._create_single_report(
model_instance, data, save_in_attachment, model_instance, data
) )
with closing(open(result_path, 'r')) as out_stream: with closing(open(result_path, 'rb')) as out_stream:
tmpl_data = out_stream.read() tmpl_data = out_stream.read()
datadict = {} datadict = {}
else: else:
@ -53,8 +52,8 @@ class Py3oReport(models.TransientModel):
suffix='.' + filetype, prefix='p3o.report.tmp.') suffix='.' + filetype, prefix='p3o.report.tmp.')
tmpl_data = self.get_template(model_instance) tmpl_data = self.get_template(model_instance)
in_stream = StringIO(tmpl_data) in_stream = BytesIO(tmpl_data)
with closing(os.fdopen(result_fd, 'w+')) as out_stream: with closing(os.fdopen(result_fd, 'wb+')) as out_stream:
template = Template(in_stream, out_stream, escape_false=True) template = Template(in_stream, out_stream, escape_false=True)
localcontext = self._get_parser_context(model_instance, data) localcontext = self._get_parser_context(model_instance, data)
expressions = template.get_all_user_python_expression() expressions = template.get_all_user_python_expression()
@ -107,5 +106,5 @@ class Py3oReport(models.TransientModel):
report_xml.report_name, filetype, convert_seconds) report_xml.report_name, filetype, convert_seconds)
if len(model_instance) == 1: if len(model_instance) == 1:
self._postprocess_report( self._postprocess_report(
result_path, model_instance.id, save_in_attachment) result_path, model_instance.id)
return result_path return result_path

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2013 XCG Consulting (http://odoo.consulting) # Copyright 2013 XCG Consulting (http://odoo.consulting)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models from odoo import fields, models
@ -6,6 +5,7 @@ from odoo import fields, models
class Py3oServer(models.Model): class Py3oServer(models.Model):
_name = 'py3o.server' _name = 'py3o.server'
_description = 'Py3o server'
_rec_name = 'url' _rec_name = 'url'
url = fields.Char( url = fields.Char(

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Therp BV <http://therp.nl> # Copyright 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_report_py3o_fusion_server from . import test_report_py3o_fusion_server

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Therp BV <http://therp.nl> # Copyright 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import mock import mock

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<odoo> <odoo>
<record id="view_ir_actions_report_base" model="ir.ui.view"> <record id="view_ir_actions_report_base" model="ir.ui.view">
<field name="model">ir.actions.report.xml</field> <field name="model">ir.actions.report</field>
<field name="inherit_id" ref="report_py3o.py3o_report_view" /> <field name="inherit_id" ref="report_py3o.py3o_report_view" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="py3o_multi_in_one" position="after"> <field name="py3o_multi_in_one" position="after">

View File

@ -27,7 +27,6 @@
<label for="image_jpeg_quality" attrs="{'invisible': [('image_compression', '!=', 'jpeg')]}"/> <label for="image_jpeg_quality" attrs="{'invisible': [('image_compression', '!=', 'jpeg')]}"/>
<div name="image_jpeg_quality" attrs="{'invisible': [('image_compression', '!=', 'jpeg')]}"> <div name="image_jpeg_quality" attrs="{'invisible': [('image_compression', '!=', 'jpeg')]}">
<field name="image_jpeg_quality" class="oe_inline"/> <field name="image_jpeg_quality" class="oe_inline"/>
<label string=" %"/>
</div> </div>
<field name="image_reduce_resolution"/> <field name="image_reduce_resolution"/>
</group> </group>