From 0e2ade3e0ac988c511aabc067f56a15edd6c7ec8 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 8 Apr 2022 15:38:20 +0200 Subject: [PATCH 01/21] [FIX] l10n_it_reverse_charge: disable one test (for now) https://github.com/OCA/OCB/commit/674eaa3bc10210d34a02145529516da1fa1c1b66 apparently broke odoo.addons.account.tests.common.AccountTestInvoicingCommon method init_invoice() when called with two opposed values as amounts (throws odoo.exceptions.UserError: Cannot create unbalanced journal entry) One test (test_intra_EU_zero_total) disabled. If/when init_invoice() is fixed, it will trigger a failure, or the test will be rewritten to adapt to the new behaviour, whichever comes first. --- l10n_it_reverse_charge/tests/test_rc.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/l10n_it_reverse_charge/tests/test_rc.py b/l10n_it_reverse_charge/tests/test_rc.py index cf0eac3a8520..f8f0a537f0e7 100644 --- a/l10n_it_reverse_charge/tests/test_rc.py +++ b/l10n_it_reverse_charge/tests/test_rc.py @@ -96,6 +96,22 @@ def test_intra_EU_cancel_and_draft(self): self.assertEqual(invoice.state, "draft") def test_intra_EU_zero_total(self): + + with self.assertRaises(UserError): + # this is defined in odoo.addons.account.tests.common.AccountTestInvoicingCommon + self.init_invoice( + "in_invoice", + partner=self.supplier_intraEU, + post=True, + amounts=[100, -100], + taxes=self.tax_22ai, + ) + + # disable the rest of the test as it depends on this NOT to fail + return + + # TMP + # pylint: disable=W0101 invoice = self.create_invoice( self.supplier_intraEU, [100, -100], taxes=self.tax_22ai ) From b24b62f72abdc98e4e795dddbb0ede8fe2f84e8f Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:05:16 +0200 Subject: [PATCH 02/21] [FIX] account_vat_period_end_statement: fix test tags --- account_vat_period_end_statement/tests/test_vat_statement.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/account_vat_period_end_statement/tests/test_vat_statement.py b/account_vat_period_end_statement/tests/test_vat_statement.py index e659d4bc235b..785ff9a21588 100644 --- a/account_vat_period_end_statement/tests/test_vat_statement.py +++ b/account_vat_period_end_statement/tests/test_vat_statement.py @@ -5,9 +5,12 @@ from dateutil.rrule import MONTHLY +from odoo.tests import tagged + from odoo.addons.account.tests.common import AccountTestInvoicingCommon +@tagged("post_install", "-at_install") class TestTax(AccountTestInvoicingCommon): @classmethod def setUpClass(cls, chart_template_ref=None): From 9b396adada72651270e545bd680cabe2bca20e92 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:05:41 +0200 Subject: [PATCH 03/21] [FIX] l10n_it_declaration_of_intent: fix test tags --- .../tests/test_declaration_of_intent.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/l10n_it_declaration_of_intent/tests/test_declaration_of_intent.py b/l10n_it_declaration_of_intent/tests/test_declaration_of_intent.py index d5551ad3d636..dfc28d734a11 100644 --- a/l10n_it_declaration_of_intent/tests/test_declaration_of_intent.py +++ b/l10n_it_declaration_of_intent/tests/test_declaration_of_intent.py @@ -5,12 +5,14 @@ from odoo import fields from odoo.exceptions import UserError, ValidationError +from odoo.tests import tagged from odoo.tests.common import Form from odoo.tools import DEFAULT_SERVER_DATE_FORMAT from odoo.addons.account.tests.common import AccountTestInvoicingCommon +@tagged("post_install", "-at_install") class TestDeclarationOfIntent(AccountTestInvoicingCommon): @classmethod def _create_declaration(cls, partner, type_d): From 785df3fb67fe67994609c3c8e5df4360dda04419 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:06:46 +0200 Subject: [PATCH 04/21] [FIX] l10n_it_fatturapa_out_di: fix test tags --- .../tests/test_fatturapa_xml_validation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/l10n_it_fatturapa_out_di/tests/test_fatturapa_xml_validation.py b/l10n_it_fatturapa_out_di/tests/test_fatturapa_xml_validation.py index d63dd57d39af..294937eb1348 100644 --- a/l10n_it_fatturapa_out_di/tests/test_fatturapa_xml_validation.py +++ b/l10n_it_fatturapa_out_di/tests/test_fatturapa_xml_validation.py @@ -3,11 +3,12 @@ import base64 from odoo import fields -from odoo.tests import Form +from odoo.tests import Form, tagged from .fatturapa_common import FatturaPACommon +@tagged("post_install", "-at_install") class TestFatturaPAXMLValidation(FatturaPACommon): def setUp(self): super(TestFatturaPAXMLValidation, self).setUp() From 9dc98988b7e5629f858841f840feb249871c8f29 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:07:25 +0200 Subject: [PATCH 05/21] [FIX] l10n_it_fatturapa_out_rc: fix test tags --- l10n_it_fatturapa_out_rc/tests/test_fatturapa_xml_validation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/l10n_it_fatturapa_out_rc/tests/test_fatturapa_xml_validation.py b/l10n_it_fatturapa_out_rc/tests/test_fatturapa_xml_validation.py index 72fa21d46e05..deac0b35266c 100644 --- a/l10n_it_fatturapa_out_rc/tests/test_fatturapa_xml_validation.py +++ b/l10n_it_fatturapa_out_rc/tests/test_fatturapa_xml_validation.py @@ -5,12 +5,14 @@ from odoo import fields from odoo.exceptions import UserError +from odoo.tests import tagged from odoo.tests.common import Form from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import FatturaPACommon from odoo.addons.l10n_it_reverse_charge.tests.rc_common import ReverseChargeCommon +@tagged("post_install", "-at_install") class TestFatturaPAXMLValidation(ReverseChargeCommon, FatturaPACommon): def setUp(self): super().setUp() From 7b47ce0aa90716b64d0e9f4f3656c589d81e39c0 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:07:55 +0200 Subject: [PATCH 06/21] [FIX] l10n_it_fatturapa_out_sp: fix test tags --- .../tests/test_fatturapa_xml_validation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/l10n_it_fatturapa_out_sp/tests/test_fatturapa_xml_validation.py b/l10n_it_fatturapa_out_sp/tests/test_fatturapa_xml_validation.py index 2cd498e4ee8e..10077e74cec0 100644 --- a/l10n_it_fatturapa_out_sp/tests/test_fatturapa_xml_validation.py +++ b/l10n_it_fatturapa_out_sp/tests/test_fatturapa_xml_validation.py @@ -4,9 +4,12 @@ import base64 +from odoo.tests import tagged + from .fatturapa_common import FatturaPACommon +@tagged("post_install", "-at_install") class TestFatturaPAXMLValidation(FatturaPACommon): def setUp(self): super(TestFatturaPAXMLValidation, self).setUp() From 2b3051c1163e47919d8aa6e0ac800595810e0a16 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:08:29 +0200 Subject: [PATCH 07/21] [FIX] l10n_it_fatturapa_pec: fix test tags --- l10n_it_fatturapa_pec/tests/test_e_invoice_response.py | 2 ++ l10n_it_fatturapa_pec/tests/test_e_invoice_send.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py b/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py index 2c0f713385d5..214c49e1dd63 100644 --- a/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py +++ b/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py @@ -6,11 +6,13 @@ from odoo.fields import Datetime from odoo.modules import get_module_resource +from odoo.tests import tagged from odoo.tools import mute_logger, pycompat from .e_invoice_common import EInvoiceCommon +@tagged("post_install", "-at_install") class TestEInvoiceResponse(EInvoiceCommon): def setUp(self): super(TestEInvoiceResponse, self).setUp() diff --git a/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py b/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py index c2c917942f86..da8848a8ea6d 100644 --- a/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py +++ b/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py @@ -2,11 +2,13 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo.exceptions import UserError +from odoo.tests import tagged from odoo.tools import mute_logger from .e_invoice_common import EInvoiceCommon +@tagged("post_install", "-at_install") class TestEInvoiceSend(EInvoiceCommon): def setUp(self): super(TestEInvoiceSend, self).setUp() From afe626490d614219b6047b22fcce153d070626f8 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:08:57 +0200 Subject: [PATCH 08/21] [FIX] l10n_it_fiscal_document_type: fix test tags --- l10n_it_fiscal_document_type/tests/test_doc_type.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/l10n_it_fiscal_document_type/tests/test_doc_type.py b/l10n_it_fiscal_document_type/tests/test_doc_type.py index d31c7b3b1e7a..85795a61717e 100644 --- a/l10n_it_fiscal_document_type/tests/test_doc_type.py +++ b/l10n_it_fiscal_document_type/tests/test_doc_type.py @@ -1,11 +1,12 @@ # Copyright 2017 Lorenzo Battistini # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). -from odoo.tests import Form +from odoo.tests import Form, tagged from odoo.addons.account.tests.common import AccountTestInvoicingCommon +@tagged("post_install", "-at_install") class TestDocType(AccountTestInvoicingCommon): @classmethod def setUpClass(cls, chart_template_ref=None): From d3e238be85aab41691e355b4326b82a97aeb5b3d Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:09:37 +0200 Subject: [PATCH 09/21] [FIX] l10n_it_intrastat: fix test tags --- l10n_it_intrastat/tests/test_intrastat.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/l10n_it_intrastat/tests/test_intrastat.py b/l10n_it_intrastat/tests/test_intrastat.py index 2e102665e8f6..5e85e62be2da 100644 --- a/l10n_it_intrastat/tests/test_intrastat.py +++ b/l10n_it_intrastat/tests/test_intrastat.py @@ -1,9 +1,12 @@ # Copyright 2019 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests import tagged + from odoo.addons.account.tests.common import AccountTestInvoicingCommon +@tagged("post_install", "-at_install") class TestIntrastat(AccountTestInvoicingCommon): @classmethod def setUpClass(cls, chart_template_ref=None): From f0fd147805fe67c052815e7892e139c323da5a2d Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:10:11 +0200 Subject: [PATCH 10/21] [FIX] l10n_it_reverse_charge: fix test tags --- l10n_it_reverse_charge/tests/test_rc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/l10n_it_reverse_charge/tests/test_rc.py b/l10n_it_reverse_charge/tests/test_rc.py index f8f0a537f0e7..f34324d6ca1f 100644 --- a/l10n_it_reverse_charge/tests/test_rc.py +++ b/l10n_it_reverse_charge/tests/test_rc.py @@ -4,10 +4,12 @@ import json from odoo.exceptions import UserError +from odoo.tests import tagged from .rc_common import ReverseChargeCommon +@tagged("post_install", "-at_install") class TestReverseCharge(ReverseChargeCommon): def test_intra_EU_invoice_line_no_tax(self): invoice = self.create_invoice(self.supplier_intraEU, [], post=False) From 33626b449b3dfab390b38a5d0c3142b305b64b26 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:10:34 +0200 Subject: [PATCH 11/21] [FIX] l10n_it_account: fix test tags --- l10n_it_account/tests/test_l10n_it_account.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/l10n_it_account/tests/test_l10n_it_account.py b/l10n_it_account/tests/test_l10n_it_account.py index 8d119c02a610..f67c6ad80f8c 100644 --- a/l10n_it_account/tests/test_l10n_it_account.py +++ b/l10n_it_account/tests/test_l10n_it_account.py @@ -2,11 +2,13 @@ from odoo import fields from odoo.exceptions import ValidationError +from odoo.tests import tagged from odoo.tests.common import Form from odoo.addons.account.tests.common import AccountTestInvoicingCommon +@tagged("post_install", "-at_install") class TestAccount(AccountTestInvoicingCommon): @classmethod def setUpClass(cls, chart_template_ref=None): From 569351d6585ca399ab1cb6079d776ed121353501 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:10:56 +0200 Subject: [PATCH 12/21] [FIX] l10n_it_split_payment: fix test tags --- l10n_it_split_payment/tests/test_splitpayment.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/l10n_it_split_payment/tests/test_splitpayment.py b/l10n_it_split_payment/tests/test_splitpayment.py index bc3f723c4270..ad86d41cb835 100644 --- a/l10n_it_split_payment/tests/test_splitpayment.py +++ b/l10n_it_split_payment/tests/test_splitpayment.py @@ -3,9 +3,12 @@ # Copyright 2016 Alessio Gerace - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.tests import tagged + from odoo.addons.account.tests.test_account_account import TestAccountAccount +@tagged("post_install", "-at_install") class TestSP(TestAccountAccount): def setUp(self): super().setUp() From c019630215360871b8738c9241547c734adce87e Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:11:16 +0200 Subject: [PATCH 13/21] [FIX] l10n_it_vat_registries_split_payment: fix test tags --- l10n_it_vat_registries_split_payment/tests/test_sp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/l10n_it_vat_registries_split_payment/tests/test_sp.py b/l10n_it_vat_registries_split_payment/tests/test_sp.py index 2612708e93f9..e25288e255f2 100644 --- a/l10n_it_vat_registries_split_payment/tests/test_sp.py +++ b/l10n_it_vat_registries_split_payment/tests/test_sp.py @@ -1,9 +1,10 @@ from odoo import fields -from odoo.tests import Form +from odoo.tests import Form, tagged from odoo.addons.account.tests.common import AccountTestInvoicingCommon +@tagged("post_install", "-at_install") class TestSP(AccountTestInvoicingCommon): @classmethod def setUpClass(cls, chart_template_ref=None): From 9d7e2ef28c1cb38fa36311d60f63e39ee2c9496e Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:11:55 +0200 Subject: [PATCH 14/21] [FIX] l10n_it_vat_statement_split_payment: fix test tags --- .../tests/test_vat_statement_split.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/l10n_it_vat_statement_split_payment/tests/test_vat_statement_split.py b/l10n_it_vat_statement_split_payment/tests/test_vat_statement_split.py index aedc8c7c72fa..1441031aec3f 100644 --- a/l10n_it_vat_statement_split_payment/tests/test_vat_statement_split.py +++ b/l10n_it_vat_statement_split_payment/tests/test_vat_statement_split.py @@ -6,9 +6,12 @@ from dateutil.rrule import MONTHLY +from odoo.tests import tagged + from odoo.addons.account.tests.common import AccountTestInvoicingCommon +@tagged("post_install", "-at_install") class TestTaxSP(AccountTestInvoicingCommon): @classmethod def setUpClass(cls, chart_template_ref=None): From 7ec14ad9e0b4ad53ca915de36359c7142e383d33 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 11:12:29 +0200 Subject: [PATCH 15/21] [FIX] l10n_it_withholding_tax_payment: fix test tags --- .../tests/test_withholding_tax_payment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/l10n_it_withholding_tax_payment/tests/test_withholding_tax_payment.py b/l10n_it_withholding_tax_payment/tests/test_withholding_tax_payment.py index 09c9252bd75a..23a79266bf12 100644 --- a/l10n_it_withholding_tax_payment/tests/test_withholding_tax_payment.py +++ b/l10n_it_withholding_tax_payment/tests/test_withholding_tax_payment.py @@ -1,11 +1,12 @@ # Copyright 2021 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo.tests import Form +from odoo.tests import Form, tagged from odoo.addons.account.tests.common import AccountTestInvoicingCommon +@tagged("post_install", "-at_install") class TestWithholdingTaxPayment(AccountTestInvoicingCommon): @classmethod def setup_withholding_tax(cls, company_data): From dabbabd7e94647ccb0d724d8f83d62f78e9a1e9d Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 12:05:22 +0200 Subject: [PATCH 16/21] [FIX] l10n_it_fatturapa_out: fix test tags --- l10n_it_fatturapa_out/tests/test_fatturapa_out_noteline.py | 3 ++- l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/l10n_it_fatturapa_out/tests/test_fatturapa_out_noteline.py b/l10n_it_fatturapa_out/tests/test_fatturapa_out_noteline.py index d27713a90663..a2d054cec475 100644 --- a/l10n_it_fatturapa_out/tests/test_fatturapa_out_noteline.py +++ b/l10n_it_fatturapa_out/tests/test_fatturapa_out_noteline.py @@ -5,11 +5,12 @@ from lxml import etree from odoo import fields -from odoo.tests import Form +from odoo.tests import Form, tagged from .fatturapa_common import FatturaPACommon +@tagged("post_install", "-at_install") class TestFatturaOutNoteLine(FatturaPACommon): def setUp(self): super().setUp() diff --git a/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py b/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py index bc2244e68d0d..7cf3b108c125 100644 --- a/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py +++ b/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py @@ -9,12 +9,13 @@ from odoo import fields from odoo.exceptions import UserError -from odoo.tests import Form +from odoo.tests import Form, tagged from odoo.tools import mute_logger from .fatturapa_common import FatturaPACommon +@tagged("post_install", "-at_install") class TestDuplicatedAttachment(FatturaPACommon): def test_duplicated_attachment(self): """Attachment name must be unique""" @@ -35,6 +36,7 @@ def test_duplicated_attachment(self): self.assertEqual(ie.exception.pgcode, "23505") +@tagged("post_install", "-at_install") class TestFatturaPAXMLValidation(FatturaPACommon): def setUp(self): super(TestFatturaPAXMLValidation, self).setUp() From fd8b44c520d329f52e1cb5cbda1d747c23005cbc Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 17 Dec 2021 17:49:51 +0100 Subject: [PATCH 17/21] [IMP] l10n_it_fatturapa_out: supporto per la conversione degli importi in EUR per fatture in valuta estera --- .../data/invoice_it_template.xml | 47 ++++++-- l10n_it_fatturapa_out/models/company.py | 20 ++++ .../tests/data/IT06363391001_00009.xml | 104 ---------------- .../tests/data/IT06363391001_00015.xml | 105 +++++++++++++++++ .../tests/data/IT06363391001_00016.xml | 105 +++++++++++++++++ .../tests/test_fatturapa_xml_validation.py | 111 +++++++++--------- l10n_it_fatturapa_out/views/company_view.xml | 14 ++- l10n_it_fatturapa_out/wizard/efattura.py | 22 +++- .../wizard/wizard_export_fatturapa.py | 13 ++ 9 files changed, 371 insertions(+), 170 deletions(-) delete mode 100644 l10n_it_fatturapa_out/tests/data/IT06363391001_00009.xml create mode 100644 l10n_it_fatturapa_out/tests/data/IT06363391001_00015.xml create mode 100644 l10n_it_fatturapa_out/tests/data/IT06363391001_00016.xml diff --git a/l10n_it_fatturapa_out/data/invoice_it_template.xml b/l10n_it_fatturapa_out/data/invoice_it_template.xml index 2a4ef2bd1922..54e3138e782e 100644 --- a/l10n_it_fatturapa_out/data/invoice_it_template.xml +++ b/l10n_it_fatturapa_out/data/invoice_it_template.xml @@ -170,7 +170,9 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati) - + INVCONT + + Valuta + + + + @@ -217,9 +229,11 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati) + - + - + + --> + @@ -600,10 +627,10 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati) + + diff --git a/l10n_it_fatturapa_out/models/company.py b/l10n_it_fatturapa_out/models/company.py index fcbf2fe3c24c..3ba9073a0dbc 100644 --- a/l10n_it_fatturapa_out/models/company.py +++ b/l10n_it_fatturapa_out/models/company.py @@ -1,9 +1,12 @@ # Copyright 2019 Roberto Fichera +# Copyright 2022 Marco Colombo # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). from odoo import _, api, fields, models from odoo.exceptions import ValidationError +_DEFAULT_XML_DIVISA_VALUE = "force_eur" + class ResCompany(models.Model): _inherit = "res.company" @@ -15,6 +18,15 @@ class ResCompany(models.Model): "in a single XML file. 0=Unlimited", ) + xml_divisa_value = fields.Selection( + [ + ("keep_orig", "Keep original"), + ("force_eur", "Force euro"), + ], + string="XML Divisa value", + default=_DEFAULT_XML_DIVISA_VALUE, + ) + @api.constrains("max_invoice_in_xml") def _validate_max_invoice_in_xml(self): if self.max_invoice_in_xml < 0: @@ -33,12 +45,20 @@ class AccountConfigSettings(models.TransientModel): related="company_id.max_invoice_in_xml", readonly=False ) + xml_divisa_value = fields.Selection( + related="company_id.xml_divisa_value", readonly=False + ) + @api.onchange("company_id") def onchange_company_id(self): res = super(AccountConfigSettings, self).onchange_company_id() if self.company_id: company = self.company_id self.max_invoice_in_xml = company.max_invoice_in_xml or 0 + self.xml_divisa_value = ( + company.xml_divisa_value or _DEFAULT_XML_DIVISA_VALUE + ) else: self.max_invoice_in_xml = 0 + self.xml_divisa_value = _DEFAULT_XML_DIVISA_VALUE return res diff --git a/l10n_it_fatturapa_out/tests/data/IT06363391001_00009.xml b/l10n_it_fatturapa_out/tests/data/IT06363391001_00009.xml deleted file mode 100644 index 94ccc4e7d2ab..000000000000 --- a/l10n_it_fatturapa_out/tests/data/IT06363391001_00009.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - IT - 06363391001 - - 00009 - FPR12 - XXXXXXX - - 06543534343 - info@yourcompany.example.com - - - - - - IT - 06363391001 - - - YourCompany - - RF01 - - - Via Milano, 1 - 00100 - Roma - AK - IT - - - 06543534343 - info@yourcompany.example.com - - - - - - AE - 99999999999 - - - Foreign Customer - - - - 29-17 Al Thanya St - 00000 - Dubai - EE - AE - - - - - - - TD01 - AED - 2018-01-07 - INV/2018/0018 - 14.00 - SI - - - - - 1 - Mouse Optical - 1.000 - Unit(s) - 8.19672 - 8.20 - 22.00 - - - 2 - Zed+ Antivirus - 1.000 - Unit(s) - 3.27869 - 3.28 - 22.00 - - - 22.00 - 11.48 - 2.52 - - - - TP02 - - MP05 - 2018-02-28 - 14.00 - - - - diff --git a/l10n_it_fatturapa_out/tests/data/IT06363391001_00015.xml b/l10n_it_fatturapa_out/tests/data/IT06363391001_00015.xml new file mode 100644 index 000000000000..0aab977ff77b --- /dev/null +++ b/l10n_it_fatturapa_out/tests/data/IT06363391001_00015.xml @@ -0,0 +1,105 @@ + + + + + + IT + 06363391001 + + 00015 + FPA12 + UFPQ1O + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 06363391001 + + 06363391001 + + Public Administration + + + + Via Roma, 1 + 10100 + Torino + AK + IT + + + + + + + TD01 + EUR + 2021-12-16 + INV/2021/12/0001 + 14.00 + SI + + + + + 1 + Cabinet with Doors + 1.000 + Unit(s) + 14.00000 + 14.00 + 0.00 + N3.2 + + Valuta + USD + 16.38000 + 2021-12-16 + + + + 0.00 + N3.2 + 14.00 + 0.00 + Not subject to VAT law + + + + TP02 + + MP05 + 2022-01-31 + 14.00 + + + + diff --git a/l10n_it_fatturapa_out/tests/data/IT06363391001_00016.xml b/l10n_it_fatturapa_out/tests/data/IT06363391001_00016.xml new file mode 100644 index 000000000000..ca62e8138b71 --- /dev/null +++ b/l10n_it_fatturapa_out/tests/data/IT06363391001_00016.xml @@ -0,0 +1,105 @@ + + + + + + IT + 06363391001 + + 00016 + FPA12 + UFPQ1O + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 06363391001 + + 06363391001 + + Public Administration + + + + Via Roma, 1 + 10100 + Torino + AK + IT + + + + + + + TD01 + USD + 2021-12-16 + INV/2021/12/0001 + 16.38 + SI + + + + + 1 + Cabinet with Doors + 1.000 + Unit(s) + 14.00000 + 14.00 + 0.00 + N3.2 + + Valuta + USD + 16.38000 + 2021-12-16 + + + + 0.00 + N3.2 + 14.00 + 0.00 + Not subject to VAT law + + + + TP02 + + MP05 + 2022-01-31 + 16.38 + + + + diff --git a/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py b/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py index 7cf3b108c125..efcfdb971039 100644 --- a/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py +++ b/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py @@ -452,62 +452,6 @@ def test_8_xml_export(self): xml_content = base64.decodebytes(attachment.datas) self.check_content(xml_content, "IT06363391001_00008.xml") - def test_9_xml_export(self): - self.tax_22.price_include = True - self.set_sequences(18, "2018-01-07") - partner = self.res_partner_fatturapa_4 - partner.onchange_country_id_e_inv() - partner.write(partner._convert_to_write(partner._cache)) - self.assertEqual(partner.codice_destinatario, "XXXXXXX") - invoice = self.invoice_model.create( - { - "name": "INV/2018/0018", - "invoice_date": "2018-01-07", - "partner_id": partner.id, - "journal_id": self.sales_journal.id, - # "account_id": self.a_recv.id, - "invoice_payment_term_id": self.account_payment_term.id, - "user_id": self.user_demo.id, - "move_type": "out_invoice", - "currency_id": self.AED.id, - "invoice_line_ids": [ - ( - 0, - 0, - { - "account_id": self.a_sale.id, - "product_id": self.product_product_10.id, - "name": "Mouse Optical", - "quantity": 1, - "product_uom_id": self.product_uom_unit.id, - "price_unit": 10, - "tax_ids": [(6, 0, {self.tax_22.id})], - }, - ), - ( - 0, - 0, - { - "account_id": self.a_sale.id, - "product_id": self.product_order_01.id, - "name": "Zed+ Antivirus", - "quantity": 1, - "product_uom_id": self.product_uom_unit.id, - "price_unit": 4, - "tax_ids": [(6, 0, {self.tax_22.id})], - }, - ), - ], - } - ) - invoice._post() - res = self.run_wizard(invoice.id) - attachment = self.attach_model.browse(res["res_id"]) - self.set_e_invoice_file_id(attachment, "IT06363391001_00009.xml") - - xml_content = base64.decodebytes(attachment.datas) - self.check_content(xml_content, "IT06363391001_00009.xml") - def test_10_xml_export(self): # invoice with descriptive line self.set_sequences(10, "2019-08-07") @@ -750,6 +694,61 @@ def test_14_xml_export(self): xml_content = base64.decodebytes(attachment.datas) self.check_content(xml_content, "IT06363391001_00014.xml") + def test_15_xml_export(self): + """ + - create an invoice in USD + + expect an XML with values in EUR + """ + + usd = self.env.ref("base.USD") + + self.env["res.currency.rate"].create( + { + "name": fields.Date.from_string("2021-12-16"), + "rate": 1.17, + "currency_id": usd.id, + "company_id": self.env.company.id, + } + ) + + invoice_form = Form( + self.env["account.move"].with_context({"default_move_type": "out_invoice"}) + ) + invoice_form.currency_id = usd + invoice_form.partner_id = self.res_partner_fatturapa_0 + invoice_form.name = "INV/2021/12/0001" + invoice_form.date = fields.Date.from_string("2021-12-16") + invoice_form.invoice_date = fields.Date.from_string("2021-12-16") + invoice_form.invoice_payment_term_id = self.account_payment_term + + self.tax_00_ns.kind_id = self.env.ref("l10n_it_account_tax_kind.n3_2") + + with invoice_form.line_ids.new() as line_form: + line_form.product_id = self.product_product_10 + line_form.account_id = self.a_sale + line_form.tax_ids.clear() + line_form.tax_ids.add(self.tax_00_ns) + invoice = invoice_form.save() + invoice.action_post() + + invoice.company_id.xml_divisa_value = "force_eur" + res = self.run_wizard(invoice.id) + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00015.xml") + + xml_content = base64.decodebytes(attachment.datas) + self.check_content(xml_content, "IT06363391001_00015.xml") + attachment.unlink() + + invoice.company_id.xml_divisa_value = "keep_orig" + res = self.run_wizard(invoice.id) + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00016.xml") + + xml_content = base64.decodebytes(attachment.datas) + self.check_content(xml_content, "IT06363391001_00016.xml") + def test_no_tax_fail(self): """ - create an invoice with a product line without taxes diff --git a/l10n_it_fatturapa_out/views/company_view.xml b/l10n_it_fatturapa_out/views/company_view.xml index f50771ba8ac1..4af49e26c90a 100644 --- a/l10n_it_fatturapa_out/views/company_view.xml +++ b/l10n_it_fatturapa_out/views/company_view.xml @@ -15,10 +15,20 @@ position="after" >
-
+
+
diff --git a/l10n_it_fatturapa_out/wizard/efattura.py b/l10n_it_fatturapa_out/wizard/efattura.py index fa5e7d0f696d..8cb2a07a7ae0 100644 --- a/l10n_it_fatturapa_out/wizard/efattura.py +++ b/l10n_it_fatturapa_out/wizard/efattura.py @@ -99,7 +99,7 @@ def format_phone(number): return number return False - def format_price(line, sign=1): + def format_price(line, sign=1, original_currency=False): res = line.price_unit if line.tax_ids and line.tax_ids[0].price_include: res = line.price_unit / (1 + (line.tax_ids[0].amount / 100)) @@ -114,6 +114,10 @@ def format_price(line, sign=1): if line.quantity < 0: res = -res + # force EUR unless we want the original currency + if not original_currency: + res = fpa_to_eur(res, line.move_id) + # XXX arrotondamento? res = "{prezzo:.{precision}f}".format( prezzo=sign * res, precision=price_precision @@ -260,6 +264,20 @@ def get_importo(line): return False return line.price_unit * line.discount / 100 + def get_importo_totale(invoice): + # wrapper to a method in wizard (for better overriding) + wiz = self.env["wizard.export.fatturapa"] + return wiz.getImportoTotale(invoice) + + def fpa_to_eur(amount, invoice): + currency = invoice.currency_id + euro = self.env.ref("base.EUR") + if currency == euro: + return amount + return currency._convert( + amount, euro, invoice.company_id, invoice.date, False + ) + if self.partner_id.commercial_partner_id.is_pa: # check value code code = self.partner_id.ipa_code @@ -291,9 +309,11 @@ def get_importo(line): "unidecode": unidecode, "wizard": self.wizard, "get_importo": get_importo, + "get_importo_totale": get_importo_totale, "all_taxes": { invoice.id: get_all_taxes(invoice) for invoice in self.invoices }, + "fpa_to_eur": fpa_to_eur, } return template_values diff --git a/l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py index 056d09df3c53..a2b56ed95395 100644 --- a/l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py @@ -74,6 +74,19 @@ def getPartnerId(self, invoice_ids): return partner + @api.model + def getImportoTotale(self, invoice): + """Entry point for other modules to override computation of + ImportoTotaleDocumento""" + # this requires a better refactoring. We SHOULD be able to use + # amount_total as is, w/o further computations. + # At the moment, some modules store the total amount to be paid + # by the customer, and handle the printed total in the print + # report (there are cases in which the partner does not have to + # paid the VAT, yet its amount has to be printed out and included + # in the total amount of the invoice) + return invoice.amount_total + def group_invoices_by_partner(self): def split_list(my_list, size): it = iter(my_list) From 1e862c343b5ec9e9e324d7041d0e5975858025b7 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 14 Jan 2022 13:06:28 +0100 Subject: [PATCH 18/21] [IMP] l10n_it_fatturapa_out_sp: supporto per la conversione degli importi in EUR per fatture in valuta estera --- l10n_it_fatturapa_out_sp/__init__.py | 3 +++ l10n_it_fatturapa_out_sp/__manifest__.py | 6 ++---- .../view/invoice_it_template.xml | 18 ------------------ l10n_it_fatturapa_out_sp/wizard/__init__.py | 3 +++ .../wizard/wizard_export_fatturapa.py | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 22 deletions(-) delete mode 100644 l10n_it_fatturapa_out_sp/view/invoice_it_template.xml create mode 100644 l10n_it_fatturapa_out_sp/wizard/__init__.py create mode 100644 l10n_it_fatturapa_out_sp/wizard/wizard_export_fatturapa.py diff --git a/l10n_it_fatturapa_out_sp/__init__.py b/l10n_it_fatturapa_out_sp/__init__.py index e69de29bb2d1..4b19b1a70022 100644 --- a/l10n_it_fatturapa_out_sp/__init__.py +++ b/l10n_it_fatturapa_out_sp/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2022 Marco Colombo + +from . import wizard diff --git a/l10n_it_fatturapa_out_sp/__manifest__.py b/l10n_it_fatturapa_out_sp/__manifest__.py index 739439cecb85..b7f11ae291f3 100644 --- a/l10n_it_fatturapa_out_sp/__manifest__.py +++ b/l10n_it_fatturapa_out_sp/__manifest__.py @@ -7,14 +7,12 @@ "category": "Localization/Italy", "summary": "Scissione pagamenti in fatturapa", "author": "Marco Colombo," "Odoo Community Association (OCA)", - "website": "https://github.com/OCA/l10n-italy" "l10n_it_fatturapa_out_sp", + "website": "https://github.com/OCA/l10n-italy", "license": "AGPL-3", "depends": [ "l10n_it_fatturapa_out", "l10n_it_split_payment", ], - "data": [ - "view/invoice_it_template.xml", - ], "installable": True, + "autoinstall": True, } diff --git a/l10n_it_fatturapa_out_sp/view/invoice_it_template.xml b/l10n_it_fatturapa_out_sp/view/invoice_it_template.xml deleted file mode 100644 index a106a951f782..000000000000 --- a/l10n_it_fatturapa_out_sp/view/invoice_it_template.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - diff --git a/l10n_it_fatturapa_out_sp/wizard/__init__.py b/l10n_it_fatturapa_out_sp/wizard/__init__.py new file mode 100644 index 000000000000..cf085ece47be --- /dev/null +++ b/l10n_it_fatturapa_out_sp/wizard/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2022 Marco Colombo + +from . import wizard_export_fatturapa diff --git a/l10n_it_fatturapa_out_sp/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_sp/wizard/wizard_export_fatturapa.py new file mode 100644 index 000000000000..be1e12e8af8e --- /dev/null +++ b/l10n_it_fatturapa_out_sp/wizard/wizard_export_fatturapa.py @@ -0,0 +1,15 @@ +# Copyright 2022 Marco Colombo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class WizardExportFatturapa(models.TransientModel): + _inherit = "wizard.export.fatturapa" + + @api.model + def getImportoTotale(self, invoice): + amount_total = super().getImportoTotale(invoice) + if invoice.split_payment: + amount_total += invoice.amount_sp + return amount_total From 07f73cecd266db26356b22b00e04caed0d0ff657 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 11 Feb 2022 12:40:30 +0100 Subject: [PATCH 19/21] [IMP] l10n_it_fatturapa_out_rc: supporto per la conversione degli importi in EUR per fatture in valuta estera --- .../views/invoice_it_template.xml | 18 ++++++++---------- l10n_it_fatturapa_out_rc/wizard/efattura.py | 11 ++--------- .../wizard/wizard_export_fatturapa.py | 19 ++++++++++++++++++- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/l10n_it_fatturapa_out_rc/views/invoice_it_template.xml b/l10n_it_fatturapa_out_rc/views/invoice_it_template.xml index f598caf3a1f5..e9c4dccb7710 100644 --- a/l10n_it_fatturapa_out_rc/views/invoice_it_template.xml +++ b/l10n_it_fatturapa_out_rc/views/invoice_it_template.xml @@ -50,22 +50,20 @@ t-esc="record.fiscal_document_type_id.code" /> - - - + + @@ -86,7 +84,7 @@ diff --git a/l10n_it_fatturapa_out_rc/wizard/efattura.py b/l10n_it_fatturapa_out_rc/wizard/efattura.py index f4d24d56a9dd..77fa143a106e 100644 --- a/l10n_it_fatturapa_out_rc/wizard/efattura.py +++ b/l10n_it_fatturapa_out_rc/wizard/efattura.py @@ -6,17 +6,10 @@ ) +# extend the EFatturaOut class to add a new helper function class EFatturaOut(_EFatturaOut): def get_template_values(self): - def get_sign(invoice): - sign = 1 - if invoice.move_type in [ - "out_refund", - "in_refund", - ] and invoice.fiscal_document_type_id.code not in ["TD04", "TD08"]: - sign = -1 - return sign - + get_sign = self.env["wizard.export.fatturapa"].getSign template_values = super().get_template_values() template_values.update({"get_sign": get_sign}) return template_values diff --git a/l10n_it_fatturapa_out_rc/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_rc/wizard/wizard_export_fatturapa.py index 0b6c85346375..27451866b7d6 100644 --- a/l10n_it_fatturapa_out_rc/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out_rc/wizard/wizard_export_fatturapa.py @@ -1,7 +1,7 @@ # Copyright 2021 Alex Comba - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models +from odoo import api, models from .efattura import EFatturaOut @@ -9,5 +9,22 @@ class WizardExportFatturapa(models.TransientModel): _inherit = "wizard.export.fatturapa" + @api.model def _get_efattura_class(self): return EFatturaOut + + @api.model + def getSign(self, invoice): + sign = 1 + if invoice.move_type in [ + "out_refund", + "in_refund", + ] and invoice.fiscal_document_type_id.code not in ["TD04", "TD08"]: + sign = -1 + return sign + + @api.model + def getImportoTotale(self, invoice): + amount_total = super().getImportoTotale(invoice) + amount_total *= self.getSign(invoice) + return amount_total From e11f64f11fe0cd49496df9e4f02749b5dc477302 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 8 Apr 2022 12:12:53 +0200 Subject: [PATCH 20/21] [FIX] Adjust price in USD for products used in tests env.ref("product.product_product_10") is a demo data we use in tests Prior to commit 86febae278f08864e83017d43f6aa9d67165d664 in odoo the original price (14.0 USD) was taken as EUR (from the company currency), and converted to 16.38 USD when added to a invoice with currency USD. This module used to convert it back to 14.0 EUR. After 86febae278f08864e83017d43f6aa9d67165d664, the product is added to a invoice with currency == USD with the correct price, 14.00, which is later converted to 11.97 EUR by this module. --- .../tests/data/IT06363391001_00015.xml | 12 ++++++------ .../tests/data/IT06363391001_00016.xml | 12 ++++++------ .../tests/test_fatturapa_xml_validation.py | 6 ++++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/l10n_it_fatturapa_out/tests/data/IT06363391001_00015.xml b/l10n_it_fatturapa_out/tests/data/IT06363391001_00015.xml index 0aab977ff77b..07f44f0d129f 100644 --- a/l10n_it_fatturapa_out/tests/data/IT06363391001_00015.xml +++ b/l10n_it_fatturapa_out/tests/data/IT06363391001_00015.xml @@ -64,7 +64,7 @@ EUR 2021-12-16 INV/2021/12/0001 - 14.00 + 11.97 SI
@@ -74,21 +74,21 @@ Cabinet with Doors 1.000 Unit(s) - 14.00000 - 14.00 + 11.96581 + 11.97 0.00 N3.2 Valuta USD - 16.38000 + 14.00000 2021-12-16 0.00 N3.2 - 14.00 + 11.97 0.00 Not subject to VAT law @@ -98,7 +98,7 @@ MP05 2022-01-31 - 14.00 + 11.97
diff --git a/l10n_it_fatturapa_out/tests/data/IT06363391001_00016.xml b/l10n_it_fatturapa_out/tests/data/IT06363391001_00016.xml index ca62e8138b71..ce25d80a53e6 100644 --- a/l10n_it_fatturapa_out/tests/data/IT06363391001_00016.xml +++ b/l10n_it_fatturapa_out/tests/data/IT06363391001_00016.xml @@ -64,7 +64,7 @@ USD 2021-12-16 INV/2021/12/0001 - 16.38 + 14.00 SI @@ -74,21 +74,21 @@ Cabinet with Doors 1.000 Unit(s) - 14.00000 - 14.00 + 11.96581 + 11.97 0.00 N3.2 Valuta USD - 16.38000 + 14.00000 2021-12-16 0.00 N3.2 - 14.00 + 11.97 0.00 Not subject to VAT law @@ -98,7 +98,7 @@ MP05 2022-01-31 - 16.38 + 14.00 diff --git a/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py b/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py index efcfdb971039..36610d1ab8b9 100644 --- a/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py +++ b/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py @@ -732,6 +732,12 @@ def test_15_xml_export(self): invoice = invoice_form.save() invoice.action_post() + # commit 86febae278f08864e83017d43f6aa9d67165d664 fixed this as + # a side effect: now the price is actually 14.00 USD not 16.38 + # for env.ref("product.product_product_10") + # self.assertEqual(invoice.invoice_line_ids[0].price_unit, 16.38) + self.assertEqual(invoice.invoice_line_ids[0].price_unit, 14.00) + invoice.company_id.xml_divisa_value = "force_eur" res = self.run_wizard(invoice.id) attachment = self.attach_model.browse(res["res_id"]) From e1875f3d8923577a87a73795301c867da6768410 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 15 Apr 2022 14:24:48 +0200 Subject: [PATCH 21/21] [FIX] l10n_it_sdi_channel: remove required attr from field in view --- l10n_it_sdi_channel/views/company_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_it_sdi_channel/views/company_view.xml b/l10n_it_sdi_channel/views/company_view.xml index 1d1c0c54bba0..f1b5326769ed 100644 --- a/l10n_it_sdi_channel/views/company_view.xml +++ b/l10n_it_sdi_channel/views/company_view.xml @@ -60,7 +60,7 @@ - +