# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo.addons.account_reports.tests.account_sales_report_common import AccountSalesReportCommon from odoo.tests import tagged from freezegun import freeze_time @tagged('post_install_l10n', 'post_install', '-at_install') class SwedishTaxReportTest(AccountSalesReportCommon): @classmethod @AccountSalesReportCommon.setup_country('se') def setUpClass(cls): super().setUpClass() cls.company.vat = 'SE123456789701' @freeze_time('2019-12-31') def test_generate_xml(self): first_tax = self.env.ref("account.%s_purchase_goods_tax_25_NEC" % self.company_data['company'].id) second_tax = self.env.ref("account.%s_purchase_tax_6_goods" % self.company_data['company'].id) # Create and post a move with two move lines to get some data in the report move = self.env['account.move'].create({ 'move_type': 'in_invoice', 'journal_id': self.company_data['default_journal_purchase'].id, 'partner_id': self.partner_a.id, 'invoice_date': '2019-11-12', 'date': '2019-11-12', 'invoice_line_ids': [(0, 0, { 'product_id': self.product_a.id, 'quantity': 1.0, 'name': 'product test 1', 'price_unit': 300, 'tax_ids': first_tax.ids, }), (0, 0, { 'product_id': self.product_b.id, 'quantity': 1.0, 'name': 'product test 2', 'price_unit': 200, 'tax_ids': second_tax.ids, })] }) move.action_post() report = self.env.ref('l10n_se.tax_report') options = report.get_options({}) expected_xml = """ 123456-7897 201911 0 0 0 0 0 0 0 0 0 300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 75 0 0 87 -12 """ self.assertXmlTreeEqual( self.get_xml_tree_from_string(self.env[report.custom_handler_model_name].l10n_se_export_tax_report_to_xml(options)['file_content']), self.get_xml_tree_from_string(expected_xml) )