mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP] New API + Short Hearder
This commit is contained in:
committed by
Elmeri Niemelä
parent
b346ff0ccb
commit
a88aa63739
@@ -1,4 +1,4 @@
|
||||
import ir_report
|
||||
import py3o_fusion_filetype
|
||||
import py3o_template
|
||||
import py3o_server
|
||||
from . import ir_report
|
||||
from . import py3o_fusion_filetype
|
||||
from . import py3o_template
|
||||
from . import py3o_server
|
||||
@@ -1,11 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 XCG Consulting (http://odoo.consulting)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
import os
|
||||
from openerp.osv import fields, osv
|
||||
from openerp import api, fields, models
|
||||
from openerp.report.interface import report_int
|
||||
from ..py3o_parser import Py3oParser
|
||||
from openerp.exceptions import ValidationError
|
||||
from openerp import addons
|
||||
|
||||
|
||||
class report_xml(osv.Model):
|
||||
class ReportXml(models.Model):
|
||||
""" Inherit from ir.actions.report.xml to allow customizing the template
|
||||
file. The user cam chose a template from a list.
|
||||
The list is configurable in the configuration tab, see py3o_template.py
|
||||
@@ -13,49 +17,32 @@ class report_xml(osv.Model):
|
||||
|
||||
_inherit = 'ir.actions.report.xml'
|
||||
|
||||
_columns = {
|
||||
# TODO required when report_type type is py3o, add python constraint
|
||||
'py3o_fusion_filetype': fields.many2one(
|
||||
'py3o.fusion.filetype',
|
||||
u"Output Format",
|
||||
),
|
||||
'py3o_template_id': fields.many2one(
|
||||
'py3o.template',
|
||||
u"Template",
|
||||
),
|
||||
'module': fields.char(
|
||||
u"Module",
|
||||
size=64,
|
||||
help=u"The implementer module that provides this report",
|
||||
),
|
||||
'py3o_template_fallback': fields.char(
|
||||
u"Fallback",
|
||||
size=128,
|
||||
help=(
|
||||
u"If the user does not provide a template this will be used "
|
||||
u"it should be a relative path to root of YOUR module"
|
||||
)
|
||||
),
|
||||
'report_type': fields.selection(
|
||||
[
|
||||
('qweb-pdf', u"PDF"),
|
||||
('qweb-html', u"HTML"),
|
||||
('controller', u"Controller"),
|
||||
('pdf', u"RML pdf (deprecated)"),
|
||||
('sxw', u"RML sxw (deprecated)"),
|
||||
('webkit', u"Webkit (deprecated)"),
|
||||
('py3o', u"Py3o"),
|
||||
],
|
||||
string=u"Report Type",
|
||||
required=True,
|
||||
help=u"HTML will open the report directly in your browser, "
|
||||
u"PDF will use wkhtmltopdf to render the HTML into a PDF "
|
||||
u"file and let you download it, Controller allows you to "
|
||||
u"define the url of a custom controller outputting "
|
||||
u"any kind of report.",
|
||||
)
|
||||
}
|
||||
@api.one
|
||||
@api.constrains("py3o_fusion_filetype", "report_type")
|
||||
def _check_py3o_fusion_filetype(self):
|
||||
if self.report_type == "py3o" and not self.py3o_fusion_filetype:
|
||||
raise ValidationError(
|
||||
"Field 'Output Format' is required for Py3O report")
|
||||
|
||||
py3o_fusion_filetype = fields.Many2one(
|
||||
'py3o.fusion.filetype',
|
||||
"Output Format")
|
||||
py3o_template_id = fields.Many2one(
|
||||
'py3o.template',
|
||||
"Template")
|
||||
module = fields.Char(
|
||||
"Module",
|
||||
help="The implementer module that provides this report")
|
||||
py3o_template_fallback = fields.Char(
|
||||
"Fallback",
|
||||
size=128,
|
||||
help=(
|
||||
"If the user does not provide a template this will be used "
|
||||
"it should be a relative path to root of YOUR module"
|
||||
))
|
||||
report_type = fields.Selection(selection_add=[('py3o', "Py3o")])
|
||||
|
||||
@api.cr
|
||||
def _lookup_report(self, cr, name):
|
||||
"""Look up a report definition.
|
||||
"""
|
||||
@@ -95,4 +82,4 @@ class report_xml(osv.Model):
|
||||
if new_report:
|
||||
return new_report
|
||||
else:
|
||||
return super(report_xml, self)._lookup_report(cr, name)
|
||||
return super(ReportXml, self)._lookup_report(cr, name)
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
from openerp.osv import fields, osv
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 XCG Consulting (http://odoo.consulting)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from openerp import fields, models
|
||||
|
||||
|
||||
class py3o_fusion_filetype(osv.Model):
|
||||
class Py3oFusionFiletype(models.Model):
|
||||
_name = 'py3o.fusion.filetype'
|
||||
|
||||
_rec_name = 'human_ext'
|
||||
|
||||
_columns = {
|
||||
'fusion_ext': fields.char(
|
||||
u"Fusion Extension",
|
||||
size=8,
|
||||
),
|
||||
'human_ext': fields.char(
|
||||
u"Human readble extension",
|
||||
size=8,
|
||||
),
|
||||
}
|
||||
fusion_ext = fields.Char("Fusion Extension", siez=8)
|
||||
human_ext = fields.Char("Human readble extension", size=8)
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
from openerp.osv import fields, osv
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 XCG Consulting (http://odoo.consulting)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from openerp import fields, models
|
||||
|
||||
|
||||
class py3o_server(osv.Model):
|
||||
class Py3oServer(models.Model):
|
||||
_name = 'py3o.server'
|
||||
|
||||
_columns = {
|
||||
'url': fields.char(
|
||||
u"URL",
|
||||
size=256,
|
||||
),
|
||||
'is_active': fields.boolean(
|
||||
u"Active",
|
||||
)
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'is_active': True,
|
||||
}
|
||||
url = fields.Char("URL", required=True)
|
||||
is_active = fields.Boolean("Active", default=True)
|
||||
|
||||
@@ -1,28 +1,19 @@
|
||||
from openerp.osv import fields, osv
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 XCG Consulting (http://odoo.consulting)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from openerp import fields, models
|
||||
|
||||
|
||||
class py3o_template(osv.Model):
|
||||
class Py3oTemplate(models.Model):
|
||||
_name = 'py3o.template'
|
||||
|
||||
_columns = {
|
||||
'name': fields.char(
|
||||
u"Name",
|
||||
),
|
||||
|
||||
'py3o_template_data': fields.binary(
|
||||
u"LibreOffice template",
|
||||
),
|
||||
|
||||
'filetype': fields.selection(
|
||||
[
|
||||
('odt', u"ODF Text Document"),
|
||||
('ods', u"ODF Spreadsheet"),
|
||||
],
|
||||
u"LibreOffice Template File Type",
|
||||
required=True,
|
||||
),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'filetype': 'odt'
|
||||
}
|
||||
name = fields.Char(required=True)
|
||||
py3o_template_data = fields.Binary("LibreOffice template")
|
||||
filetype = fields.Selection(
|
||||
selection=[
|
||||
('odt', u"ODF Text Document"),
|
||||
('ods', u"ODF Spreadsheet"),
|
||||
],
|
||||
string="LibreOffice Template File Type",
|
||||
required=True,
|
||||
default='odt')
|
||||
|
||||
Reference in New Issue
Block a user