From 700995e12aefed04652170b07489a5dd92ebf34e Mon Sep 17 00:00:00 2001 From: Raimon Esteve Date: Wed, 14 Jun 2023 15:30:42 +0200 Subject: [PATCH] Upgrade 6.4 --- party.py | 5 +- template_facturae_macros.xml | 2 +- tests/__init__.py | 6 -- ..._facturae_electronet.py => test_module.py} | 98 ++++++++++--------- view/address_form.xml | 2 +- 5 files changed, 56 insertions(+), 57 deletions(-) rename tests/{test_account_invoice_facturae_electronet.py => test_module.py} (78%) diff --git a/party.py b/party.py index ba674f2..31be09a 100644 --- a/party.py +++ b/party.py @@ -3,15 +3,12 @@ from trytond.model import fields from trytond.pool import PoolMeta -__all__ = ['Party', 'Address'] - class Party(metaclass=PoolMeta): __name__ = 'party.party' - id_electronet = fields.Char('Id Electronet') + class Address(metaclass=PoolMeta): __name__ = 'party.address' - electronet_sale_point = fields.Char('Electronet Sale Point') diff --git a/template_facturae_macros.xml b/template_facturae_macros.xml index 261885b..19e01a1 100644 --- a/template_facturae_macros.xml +++ b/template_facturae_macros.xml @@ -11,7 +11,7 @@ {% macro address(address) %}
{{ address.street[:80] }}
- {{ address.zip[:5] }} + {{ address.postal_code[:5] }} {{ address.city[:50] }} {{ address.subdivision.name[:20] }} {{ address.country.code3 }} diff --git a/tests/__init__.py b/tests/__init__.py index f932dc5..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,6 +0,0 @@ -# This file is part account_invoice_facturae_electronet module for Tryton. -# The COPYRIGHT file at the top level of this repository contains -# the full copyright notices and license terms. -from .test_account_invoice_facturae_electronet import suite - -__all__ = ['suite'] diff --git a/tests/test_account_invoice_facturae_electronet.py b/tests/test_module.py similarity index 78% rename from tests/test_account_invoice_facturae_electronet.py rename to tests/test_module.py index 7087607..dacf1fc 100644 --- a/tests/test_account_invoice_facturae_electronet.py +++ b/tests/test_module.py @@ -9,13 +9,13 @@ from trytond.pool import Pool from trytond.transaction import Transaction from trytond.tests.test_tryton import ModuleTestCase, with_transaction from trytond.modules.account.tests import get_fiscalyear, create_chart -from trytond.modules.company.tests import create_company, set_company +from trytond.modules.company.tests import create_company, set_company, CompanyTestMixin from trytond.modules.account_invoice.tests import set_invoice_sequences from trytond.modules.currency.tests import create_currency, add_currency_rate CURRENT_PATH = os.path.dirname(os.path.abspath(__file__)) -class AccountInvoiceFacturaeElectronetTestCase(ModuleTestCase): +class AccountInvoiceFacturaeElectronetTestCase(CompanyTestMixin, ModuleTestCase): 'Test Account Invoice Facturae Electronet module' module = 'account_invoice_facturae_electronet' @@ -24,6 +24,7 @@ class AccountInvoiceFacturaeElectronetTestCase(ModuleTestCase): 'Test invoice generation' pool = Pool() + Certificate = pool.get('certificate') Account = pool.get('account.account') FiscalYear = pool.get('account.fiscalyear') Invoice = pool.get('account.invoice') @@ -67,11 +68,6 @@ class AccountInvoiceFacturaeElectronetTestCase(ModuleTestCase): company.party.save() company.save() - # Save certificate into company - with open(os.path.join( - CURRENT_PATH, 'certificate.pfx'), 'rb') as cert_file: - company.facturae_certificate = cert_file.read() - payment_term, = PaymentTerm.create([{ 'name': '20 days, 40 days', 'lines': [ @@ -97,6 +93,14 @@ class AccountInvoiceFacturaeElectronetTestCase(ModuleTestCase): }]) with set_company(company): + certificate = Certificate() + certificate.name = 'dummy Certificate' + # Save certificate + with open(os.path.join( + CURRENT_PATH, 'certificate.pfx'), 'rb') as cert_file: + certificate.pem_certificate = cert_file.read() + certificate.save() + create_chart(company, tax=True) fiscalyear = set_invoice_sequences(get_fiscalyear(company)) @@ -127,7 +131,7 @@ class AccountInvoiceFacturaeElectronetTestCase(ModuleTestCase): company_address, = company.party.addresses company_address.street = 'street' - company_address.zip = '08201' + company_address.postal_code = '08201' company_address.city = 'City' company_address.subdivision = subdivision company_address.country = country @@ -150,7 +154,7 @@ class AccountInvoiceFacturaeElectronetTestCase(ModuleTestCase): 'party': party.id, 'street': 'St sample, 15', 'city': 'City', - 'zip': '08201', + 'postal_code': '08201', 'subdivision': subdivision.id, 'country': country.id, 'electronet_sale_point': 'TEST', @@ -197,45 +201,49 @@ class AccountInvoiceFacturaeElectronetTestCase(ModuleTestCase): currency = create_currency('Eur') add_currency_rate(currency, 1) - with Transaction().set_user(0): - invoice = Invoice() - invoice.type = 'out' - invoice.on_change_type() - invoice.party = party - invoice.on_change_party() - invoice.payment_type = payment_receivable - invoice.payment_term = term - invoice.currency = currency - invoice.company = company - invoice.account = invoice.on_change_with_account() + invoice = Invoice() + invoice.type = 'out' + invoice.on_change_type() + invoice.party = party + invoice.on_change_party() + invoice.payment_type = payment_receivable + invoice.payment_term = term + invoice.currency = currency + invoice.company = company + invoice._update_account() - line1 = InvoiceLine() - line1.product = product - line1.on_change_product() - line1.on_change_account() - line1.quantity = 5 - line1.unit_price = Decimal('40') + line1 = InvoiceLine() + line1.type = 'line' + line1.invoice_type = 'out' + line1.currency = invoice.currency + line1.company = invoice.company + line1.product = product + line1.on_change_product() + line1.on_change_account() + line1.quantity = 5 + line1.unit_price = Decimal('40') - line2 = InvoiceLine() - line2.account = revenue - line2.on_change_account() - line2.product = product - line2.on_change_product() - line2.description = 'Test' - line2.quantity = 1 - line2.unit_price = Decimal(20) + line2 = InvoiceLine() + line2.type = 'line' + line2.invoice_type = 'out' + line2.currency = invoice.currency + line2.company = invoice.company + line2.account = revenue + line2.on_change_account() + line2.product = product + line2.on_change_product() + line2.description = 'Test' + line2.quantity = 1 + line2.unit_price = Decimal(20) - invoice.lines = [line1, line2] - invoice.on_change_lines() + invoice.lines = [line1, line2] + invoice.on_change_lines() - invoice.save() - Invoice.post([invoice]) + invoice.save() + Invoice.post([invoice]) - Invoice.generate_facturae_electronet([invoice]) + invoice.generate_facturae() + self.assertNotEqual(invoice.invoice_facturae, None) + self.assertEqual(invoice.invoice_facturae_filename, 'facturae-1.xsig') - -def suite(): - suite = trytond.tests.test_tryton.suite() - suite.addTests(unittest.TestLoader().loadTestsFromTestCase( - AccountInvoiceFacturaeElectronetTestCase)) - return suite +del ModuleTestCase diff --git a/view/address_form.xml b/view/address_form.xml index 80fc813..c3ae609 100644 --- a/view/address_form.xml +++ b/view/address_form.xml @@ -2,7 +2,7 @@ - +