Browse Source

Merge pull request #8 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
8b9a824ffc
  1. 1
      report_py3o/demo/.~lock.res_user.odt#
  2. 4
      report_py3o/py3o_parser.py
  3. 34
      report_py3o/tests/test_report_py3o.py
  4. 4
      report_py3o/views/ir_report.xml
  5. 4
      report_py3o/views/menu.xml
  6. 4
      report_py3o/views/py3o_server.xml
  7. 4
      report_py3o/views/py3o_template.xml

1
report_py3o/demo/.~lock.res_user.odt#

@ -1 +0,0 @@
,lmi,nbacsonelmi,04.10.2016 15:56,file:///home/lmi/.config/libreoffice/4;

4
report_py3o/py3o_parser.py

@ -166,6 +166,8 @@ class Py3oParser(report_sxw):
"datadict": json.dumps(datadict),
"image_mapping": "{}",
}
if report_xml.py3o_is_local_fusion:
fields['skipfusion'] = '1'
r = requests.post(
report_xml.py3o_server_id.url, data=fields, files=files)
if r.status_code != 200:
@ -178,7 +180,7 @@ class Py3oParser(report_sxw):
# we do nice chunked reading from the network...
chunk_size = 1024
with NamedTemporaryFile(
suffix=filetype.human_ext,
suffix=filetype,
prefix='py3o-template-'
) as fd:
for chunk in r.iter_content(chunk_size):

34
report_py3o/tests/test_report_py3o.py

@ -14,14 +14,26 @@ import openerp.tests
class TestReportPy3o(TransactionCase):
def test_reports(self):
domain = [('report_type', '=', 'py3o'),
('report_name', '=', 'py3o_user_info')]
reports = self.env['ir.actions.report.xml'].search(domain)
self.assertEqual(1, len(reports))
for r in reports:
with mock.patch('openerp.addons.report_py3o.py3o_parser.'
'Py3oParser.create_single_pdf') as patched_pdf:
r.render_report(self.env.user.ids,
r.report_name,
{})
self.assertEqual(1, patched_pdf.call_count)
report = self.env.ref("report_py3o.res_users_report_py3o")
with mock.patch('openerp.addons.report_py3o.py3o_parser.'
'Py3oParser.create_single_pdf') as patched_pdf:
# test the call the the create method inside our custom parser
report.render_report(self.env.user.ids,
report.report_name,
{})
self.assertEqual(1, patched_pdf.call_count)
res = report.render_report(
self.env.user.ids, report.report_name, {})
self.assertTrue(res)
py3o_server = self.env['py3o.server'].create({"url": "http://dummy"})
# check the call to the fusion server
report.write({"py3o_filetype": "pdf",
"py3o_server_id": py3o_server.id})
with mock.patch('requests.post') as patched_post:
magick_response = mock.MagicMock()
magick_response.status_code = 200
patched_post.return_value = magick_response
magick_response.iter_content.return_value = "test result"
res = report.render_report(
self.env.user.ids, report.report_name, {})
self.assertEqual(('test result', '.pdf'), res)

4
report_py3o/views/ir_report.xml

@ -1,4 +1,4 @@
<openerp>
<odoo>
<data>
<!-- Inherit from base.act_report_xml_view to add py3o-related settings. -->
@ -28,4 +28,4 @@
</field>
</record>
</data>
</openerp>
</odoo>

4
report_py3o/views/menu.xml

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data>
<menuitem id="py3o_config_menu"
name="Py3o"
parent="report.reporting_menuitem" />
</data>
</openerp>
</odoo>

4
report_py3o/views/py3o_server.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data>
<record id="py3o_server_configuration_form_view" model="ir.ui.view">
<field name="name">py3o.server.configuration.form.view</field>
@ -39,4 +39,4 @@
parent="py3o_config_menu"
action="py3o_server_configuration_action" />
</data>
</openerp>
</odoo>

4
report_py3o/views/py3o_template.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data>
<record id="py3o_template_configuration_search_view" model="ir.ui.view">
<field name="name">py3o.template.configuration.search.view</field>
@ -51,4 +51,4 @@
parent="py3o_config_menu"
action="py3o_template_configuration_action" />
</data>
</openerp>
</odoo>
Loading…
Cancel
Save