| 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 TestJpUBLPint(AccountTestInvoicingCommon): |
| 13 |
|
| 14 |
@classmethod |
| 15 |
@AccountTestInvoicingCommon.setup_country('jp') |
| 16 |
def setUpClass(cls): |
| 17 |
super().setUpClass() |
| 18 |
|
| 19 |
cls.other_currency = cls.setup_other_currency('USD') |
| 20 |
|
| 21 |
|
| 22 |
cls.company_data['company'].write({ |
| 23 |
'vat': '7482543580381', |
| 24 |
'street': '池上通り', |
| 25 |
'zip': '140-0004', |
| 26 |
'city': '品川区', |
| 27 |
'state_id': cls.env.ref('base.state_jp_jp-19').id, |
| 28 |
'phone': '+81 90-1234-5678', |
| 29 |
}) |
| 30 |
cls.partner_a.write({ |
| 31 |
'vat': 'T7000012050002', |
| 32 |
'street': '3F 星和池袋ビル', |
| 33 |
'zip': '170-0013', |
| 34 |
'city': '豊島区', |
| 35 |
'state_id': cls.env.ref('base.state_jp_jp-13').id, |
| 36 |
'country_id': cls.env.ref('base.jp').id, |
| 37 |
'phone': '+81 3-5798-5555', |
| 38 |
}) |
| 39 |
|
| 40 |
cls.fakenow = datetime(2024, 7, 15, 10, 00, 00) |
| 41 |
cls.startClassPatcher(freeze_time(cls.fakenow)) |
| 42 |
|
| 43 |
def test_invoice(self): |
| 44 |
invoice = self.init_invoice('out_invoice', currency=self.other_currency, products=self.product_a) |
| 45 |
invoice.action_post() |
| 46 |
|
| 47 |
actual_xml, errors = self.env['account.edi.xml.pint_jp']._export_invoice(invoice) |
| 48 |
self.assertFalse(errors) |
| 49 |
|
| 50 |
with file_open('l10n_jp_ubl_pint/tests/expected_xmls/invoice.xml', 'rb') as f: |
| 51 |
expected_xml = f.read() |
| 52 |
|
| 53 |
self.assertXmlTreeEqual( |
| 54 |
self.get_xml_tree_from_string(actual_xml), |
| 55 |
self.get_xml_tree_from_string(expected_xml), |
| 56 |
) |