Skip to content

Commit 4aab7f9

Browse files
author
Alexis de Lattre
authored
Merge pull request #2 from acsone/10.0-refactor_py3o-jne
10.0 refactor py3o jne
2 parents 5ac6710 + 4048c0b commit 4aab7f9

6 files changed

Lines changed: 367 additions & 269 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ python:
1414

1515
env:
1616
global:
17-
- VERSION="9.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
17+
- VERSION="10.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
1818
- TRANSIFEX_USER='transbot@odoo-community.org'
1919
- secure: NUsXwVrMntcqge1ozKW+DSkP7dq+Rla6JVvFF2c89/g+zJaIqQRi8EQBLoqNwCdMk+rjpQeZt/JPELjH+EzPcmGddhDxOgVB3nUT9LvFXGCHF+NjmHXqyba4tuc7BnpG1WDD+rSlxVCt1aIjNIhhaZ4ic0rCWpKNYu/yFTsmChc=
2020
matrix:

report_py3o/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from . import ir_actions_report_xml
22
from . import py3o_template
33
from . import py3o_server
4+
from . import py3o_report

report_py3o/models/ir_actions_report_xml.py

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# -*- coding: utf-8 -*-
22
# Copyright 2013 XCG Consulting (http://odoo.consulting)
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4-
import os
54
import logging
65
from odoo import api, fields, models, _
7-
from odoo.report.interface import report_int
86
from odoo.exceptions import ValidationError
9-
from odoo import addons
10-
from ..py3o_parser import Py3oParser
117

128
logger = logging.getLogger(__name__)
139

@@ -85,43 +81,14 @@ def _get_py3o_filetypes(self):
8581
))
8682
report_type = fields.Selection(selection_add=[('py3o', "Py3o")])
8783

88-
@api.model_cr
89-
def _lookup_report(self, name):
90-
"""Look up a report definition.
91-
"""
92-
# START section copied from odoo/addons/base/ir/ir_actions.py
93-
# with small adaptations
94-
# First lookup in the deprecated place, because if the report
95-
# definition has not been updated, it is more likely the correct
96-
# definition is there. Only reports with custom parser
97-
# specified in Python are still there.
98-
if 'report.' + name in report_int._reports:
99-
new_report = report_int._reports['report.' + name]
100-
if not isinstance(new_report, Py3oParser):
101-
new_report = None
102-
else:
103-
self._cr.execute(
104-
"SELECT * FROM ir_act_report_xml "
105-
"WHERE report_name=%s AND report_type=%s", (name, 'py3o'))
106-
report_data = self._cr.dictfetchone()
107-
# END section copied from odoo/addons/base/ir/ir_actions.py
108-
if report_data:
109-
kwargs = {}
110-
if report_data['parser']:
111-
kwargs['parser'] = getattr(addons, report_data['parser'])
112-
113-
new_report = Py3oParser(
114-
'report.' + report_data['report_name'],
115-
report_data['model'],
116-
os.path.join('addons', report_data['report_rml'] or '/'),
117-
header=report_data['header'],
118-
register=False,
119-
**kwargs
120-
)
121-
else:
122-
new_report = None
123-
124-
if new_report:
125-
return new_report
126-
else:
127-
return super(IrActionsReportXml, self)._lookup_report(name)
84+
@api.model
85+
def render_report(self, res_ids, name, data):
86+
action_py3o_report = self.search(
87+
[("report_name", "=", name),
88+
("report_type", "=", "py3o")])
89+
if action_py3o_report:
90+
return self.env['py3o.report'].create({
91+
'ir_actions_report_xml_id': action_py3o_report.id
92+
}).create_report(res_ids, data)
93+
return super(IrActionsReportXml, self).render_report(
94+
res_ids, name, data)

0 commit comments

Comments
 (0)