[MIG] report_intrastat : Converted yml test cases to unittest
This commit is contained in:
committed by
Yannick Tivisse
parent
7725d7e683
commit
4c042cd55f
@@ -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'],
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import test_report_intrastat
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user