Browse Source

Merge pull request #2 from acsone/9.0-import_report_py3o

9.0 import report py3o
pull/80/head
Florent Aide 8 years ago
committed by GitHub
parent
commit
769f23fada
  1. 1
      report_py3o/models/ir_report.py
  2. 4
      report_py3o/models/py3o_template.py
  3. 12
      report_py3o/py3o_parser.py

1
report_py3o/models/ir_report.py

@ -39,6 +39,7 @@ class ReportXml(models.Model):
help=( help=(
"If the user does not provide a template this will be used " "If the user does not provide a template this will be used "
"it should be a relative path to root of YOUR module " "it should be a relative path to root of YOUR module "
"or an absolute path on your server."
)) ))
report_type = fields.Selection(selection_add=[('py3o', "Py3o")]) report_type = fields.Selection(selection_add=[('py3o', "Py3o")])

4
report_py3o/models/py3o_template.py

@ -11,8 +11,8 @@ class Py3oTemplate(models.Model):
py3o_template_data = fields.Binary("LibreOffice template") py3o_template_data = fields.Binary("LibreOffice template")
filetype = fields.Selection( filetype = fields.Selection(
selection=[ selection=[
('odt', u"ODF Text Document"),
('ods', u"ODF Spreadsheet"),
('odt', "ODF Text Document"),
('ods', "ODF Spreadsheet"),
], ],
string="LibreOffice Template File Type", string="LibreOffice Template File Type",
required=True, required=True,

12
report_py3o/py3o_parser.py

@ -88,13 +88,19 @@ class Py3oParser(report_sxw):
report_obj.py3o_template_id.py3o_template_data report_obj.py3o_template_id.py3o_template_data
) )
elif report_obj.py3o_template_fallback and report_obj.module:
elif report_obj.py3o_template_fallback:
tmpl_name = report_obj.py3o_template_fallback
flbk_filename = None
if report_obj.module:
# if the default is defined # if the default is defined
flbk_filename = pkg_resources.resource_filename( flbk_filename = pkg_resources.resource_filename(
"openerp.addons.%s" % report_obj.module, "openerp.addons.%s" % report_obj.module,
report_obj.py3o_template_fallback,
tmpl_name,
) )
if os.path.exists(flbk_filename):
elif os.path.isabs(tmpl_name):
# It is an absolute path
flbk_filename = os.path.normcase(os.path.normpath(tmpl_name))
if flbk_filename and os.path.exists(flbk_filename):
# and it exists on the fileystem # and it exists on the fileystem
with open(flbk_filename, 'r') as tmpl: with open(flbk_filename, 'r') as tmpl:
tmpl_data = tmpl.read() tmpl_data = tmpl.read()

Loading…
Cancel
Save