diff --git a/addons/report_intrastat/__openerp__.py b/addons/report_intrastat/__openerp__.py index 33dfa8bbc23..71510039065 100644 --- a/addons/report_intrastat/__openerp__.py +++ b/addons/report_intrastat/__openerp__.py @@ -19,5 +19,5 @@ European Union.""", 'security/report_intrastat_security.xml', 'views/report_intrastat_views.xml', ], - 'tests': ['../account/test/account_minimal_test.xml', 'test/report_intrastat_report.yml'], + 'tests': ['../account/test/account_minimal_test.xml'], } diff --git a/addons/report_intrastat/test/report_intrastat_report.yml b/addons/report_intrastat/test/report_intrastat_report.yml deleted file mode 100644 index e8790157604..00000000000 --- a/addons/report_intrastat/test/report_intrastat_report.yml +++ /dev/null @@ -1,21 +0,0 @@ -- - In order to test the PDF reports defined on an invoice, we will create a Invoice Record -- - !record {model: account.invoice, id: test_invoice_1}: - currency_id: base.EUR - company_id: base.main_company - partner_id: base.res_partner_1 - state: draft - type: out_invoice - account_id: a_recv - name: Test invoice 1 -- - In order to test the PDF reports defined using report_intrastat module, we print a Intrastat Report -- - !python {model: account.invoice}: | - import os - import openerp.report - from openerp import tools - data, format = openerp.report.render_report(cr, uid, [ref('test_invoice_1')], 'report_intrastat.report_intrastatinvoice', {}, {}) - if tools.config['test_report_directory']: - file(os.path.join(tools.config['test_report_directory'], 'report_intrastat-intrastat_report.'+format), 'wb+').write(data) diff --git a/addons/report_intrastat/tests/__init__.py b/addons/report_intrastat/tests/__init__.py new file mode 100644 index 00000000000..467c15e9fb7 --- /dev/null +++ b/addons/report_intrastat/tests/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import test_report_intrastat diff --git a/addons/report_intrastat/tests/test_report_intrastat.py b/addons/report_intrastat/tests/test_report_intrastat.py new file mode 100644 index 00000000000..fdd2b4d8e1f --- /dev/null +++ b/addons/report_intrastat/tests/test_report_intrastat.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +import os + +from odoo import tools +from odoo.tests import common +from odoo.modules.module import get_module_resource + + +class RepoortIntrastatTest(common.TransactionCase): + + def _load(self, module, *args): + tools.convert_file(self.cr, 'report_intrastat', + get_module_resource(module, *args), + {}, 'init', False, 'test', self.registry._assertion_report) + + def setUp(self): + super(RepoortIntrastatTest, self).setUp() + + self._load('account', 'test', 'account_minimal_test.xml') + self.invoice = self.env['account.invoice'].create({ + 'currency_id': self.ref('base.EUR'), + 'company_id': self.ref('base.main_company'), + 'partner_id': self.ref('base.res_partner_1'), + 'state': 'draft', + 'type': 'out_invoice', + 'account_id': self.ref('report_intrastat.a_recv'), + 'name': 'Test invoice 1' + }) + + def test_00_create_pdf(self): + data, report_format = self.env['ir.actions.report.xml'].render_report(self.invoice.ids, 'report_intrastat.report_intrastatinvoice', {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'report_intrastat-intrastat_report.' + report_format), 'wb+').write(data)