| 1 |
|
| 2 |
from datetime import datetime |
| 3 |
|
| 4 |
from freezegun import freeze_time |
| 5 |
|
| 6 |
from odoo.addons.account.tests.common import AccountTestInvoicingCommon |
| 7 |
from odoo.tools import file_open |
| 8 |
from odoo.tests import tagged |
| 9 |
|
| 10 |
|
| 11 |
@tagged('post_install_l10n', 'post_install', '-at_install') |
| 12 |
class TestAnzUBLPint(AccountTestInvoicingCommon): |
| 13 |
|
| 14 |
@classmethod |
| 15 |
@AccountTestInvoicingCommon.setup_country('au') |
| 16 |
def setUpClass(cls): |
| 17 |
super().setUpClass() |
| 18 |
|
| 19 |
cls.other_currency = cls.setup_other_currency('NZD') |
| 20 |
|
| 21 |
|
| 22 |
cls.company_data['company'].write({ |
| 23 |
'vat': '11225459588', |
| 24 |
'l10n_au_is_gst_registered': True, |
| 25 |
'street': 'Henry Lawson Drive', |
| 26 |
'zip': '2850', |
| 27 |
'city': 'Home Rule', |
| 28 |
'state_id': cls.env.ref('base.state_au_8').id, |
| 29 |
'phone': '+61 412 345 678', |
| 30 |
}) |
| 31 |
cls.partner_a.write({ |
| 32 |
'vat': '49098576', |
| 33 |
'company_registry': '9429047488083', |
| 34 |
'street': 'Victoria Street', |
| 35 |
'zip': '3247', |
| 36 |
'city': 'Hamilton', |
| 37 |
'state_id': cls.env.ref('base.state_nz_wtc').id, |
| 38 |
'country_id': cls.env.ref('base.nz').id, |
| 39 |
'phone': '+64 21 123 4567', |
| 40 |
}) |
| 41 |
|
| 42 |
cls.fakenow = datetime(2024, 7, 15, 10, 00, 00) |
| 43 |
cls.startClassPatcher(freeze_time(cls.fakenow)) |
| 44 |
|
| 45 |
def test_invoice(self): |
| 46 |
invoice = self.init_invoice('out_invoice', currency=self.other_currency, products=self.product_a) |
| 47 |
invoice.action_post() |
| 48 |
|
| 49 |
actual_xml, errors = self.env['account.edi.xml.pint_anz']._export_invoice(invoice) |
| 50 |
self.assertFalse(errors) |
| 51 |
|
| 52 |
with file_open('l10n_anz_ubl_pint/tests/expected_xmls/invoice.xml', 'rb') as f: |
| 53 |
expected_xml = f.read() |
| 54 |
|
| 55 |
self.assertXmlTreeEqual( |
| 56 |
self.get_xml_tree_from_string(actual_xml), |
| 57 |
self.get_xml_tree_from_string(expected_xml), |
| 58 |
) |