From 6f5ef2ec363dbe117a3d7f7ef26f49c868b28a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Wed, 7 Aug 2024 14:21:54 +0000 Subject: [PATCH] [MIG] l10n_br_account_nf: Migration to 15.0 --- l10n_br_account_nfe/__manifest__.py | 2 +- l10n_br_account_nfe/models/document.py | 3 +- .../tests/test_nfce_contingency.py | 45 ++++++++++--------- .../tests/test_nfe_danfe_account.py | 4 +- .../test_nfe_generate_tags_cobr_dup_pag.py | 4 +- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/l10n_br_account_nfe/__manifest__.py b/l10n_br_account_nfe/__manifest__.py index be4efe331cb7..da00e30d52de 100644 --- a/l10n_br_account_nfe/__manifest__.py +++ b/l10n_br_account_nfe/__manifest__.py @@ -13,7 +13,7 @@ "author": "Engenere," "Akretion," "Odoo Community Association (OCA)", "maintainers": ["antoniospneto", "felipemotter", "mbcosta"], "website": "https://github.com/OCA/l10n-brazil", - "version": "14.0.5.0.0", + "version": "15.0.1.0.0", "development_status": "Beta", "depends": [ "l10n_br_nfe", diff --git a/l10n_br_account_nfe/models/document.py b/l10n_br_account_nfe/models/document.py index 05a903ad88d1..a25a75a6a4bf 100644 --- a/l10n_br_account_nfe/models/document.py +++ b/l10n_br_account_nfe/models/document.py @@ -112,7 +112,8 @@ def _is_installment(self): self.ensure_one() self.move_ids.financial_move_line_ids.mapped("date_maturity") moves_terms = self.move_ids.financial_move_line_ids.filtered( - lambda move_line: move_line.date_maturity > move_line.date + lambda move_line: move_line.date_maturity + and move_line.date_maturity > move_line.date ) return True if len(moves_terms) > 0 else False diff --git a/l10n_br_account_nfe/tests/test_nfce_contingency.py b/l10n_br_account_nfe/tests/test_nfce_contingency.py index 42a87bff979f..29fd8f98b188 100644 --- a/l10n_br_account_nfe/tests/test_nfce_contingency.py +++ b/l10n_br_account_nfe/tests/test_nfce_contingency.py @@ -7,67 +7,68 @@ class TestAccountNFCeContingency(TransactionCase): - def setUp(self): - super().setUp() - # this hook is required to test l10n_br_account_nfe alone: + @classmethod + def setUpClass(cls): + super().setUpClass() hooks.register_hook( self.env, "l10n_br_nfe", "odoo.addons.l10n_br_nfe_spec.models.v4_0.leiaute_nfe_v4_00", ) - self.document_id = self.env.ref("l10n_br_nfe.demo_nfce_same_state") - self.prepare_account_move_nfce() + cls.document_id = cls.env.ref("l10n_br_nfe.demo_nfce_same_state") + cls.prepare_account_move_nfce() - def prepare_account_move_nfce(self): - receivable_account_id = self.env["account.account"].create( + @classmethod + def prepare_account_move_nfce(cls): + receivable_account_id = cls.env["account.account"].create( { "name": "TEST ACCOUNT", - "code": "1.1.1.2.2", + "code": "1-test.1.1.2.2", "reconcile": 1, - "company_id": self.env.ref("base.main_company").id, - "user_type_id": self.env.ref("account.data_account_type_receivable").id, + "company_id": cls.env.ref("base.main_company").id, + "user_type_id": cls.env.ref("account.data_account_type_receivable").id, } ) - payable_account_id = self.env["account.account"].create( + payable_account_id = cls.env["account.account"].create( { "name": "TEST ACCOUNT 2", - "code": "1.1.1.2.3", + "code": "1-test.1.1.2.3", "reconcile": 1, - "company_id": self.env.ref("base.main_company").id, - "user_type_id": self.env.ref("account.data_account_type_payable").id, + "company_id": cls.env.ref("base.main_company").id, + "user_type_id": cls.env.ref("account.data_account_type_payable").id, } ) - payment_method = self.env.ref("account.account_payment_method_manual_in").id - journal_id = self.env["account.journal"].create( + payment_method = cls.env.ref("account.account_payment_method_manual_in").id + journal_id = cls.env["account.journal"].create( { "name": "JOURNAL TEST", "code": "TEST", "type": "bank", - "company_id": self.env.ref("base.main_company").id, + "company_id": cls.env.ref("base.main_company").id, } ) - payment_mode = self.env["account.payment.mode"].create( + payment_mode = cls.env["account.payment.mode"].create( { "name": "PAYMENT MODE TEST", - "company_id": self.env.ref("base.main_company").id, + "company_id": cls.env.ref("base.main_company").id, "payment_method_id": payment_method, "fiscal_payment_mode": "15", "bank_account_link": "fixed", "fixed_journal_id": journal_id.id, } ) - self.document_move_id = self.env["account.move"].create( + cls.document_move_id = cls.env["account.move"].create( { "name": "MOVE TEST", "payment_mode_id": payment_mode.id, - "company_id": self.env.ref("base.main_company").id, + "company_id": cls.env.ref("base.main_company").id, "line_ids": [ (0, 0, {"account_id": receivable_account_id.id, "credit": 10}), (0, 0, {"account_id": payable_account_id.id, "debit": 10}), ], } ) - self.document_move_id.fiscal_document_id = self.document_id.id + cls.document_move_id.fiscal_document_id = cls.document_id.id def test_nfce_contingencia(self): self.document_id._update_nfce_for_offline_contingency() diff --git a/l10n_br_account_nfe/tests/test_nfe_danfe_account.py b/l10n_br_account_nfe/tests/test_nfe_danfe_account.py index 31c2dab2a59a..dee3686c47de 100644 --- a/l10n_br_account_nfe/tests/test_nfe_danfe_account.py +++ b/l10n_br_account_nfe/tests/test_nfe_danfe_account.py @@ -2,11 +2,11 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from unittest.mock import patch -from odoo.tests import SavepointCase, tagged +from odoo.tests import TransactionCase, tagged @tagged("post_install", "-at_install") -class TestDanfe(SavepointCase): +class TestDanfe(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py b/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py index 219658d01042..30fc8731822c 100644 --- a/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py +++ b/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py @@ -6,11 +6,11 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.exceptions import UserError -from odoo.tests import Form, SavepointCase, tagged +from odoo.tests import Form, TransactionCase, tagged @tagged("post_install", "-at_install") -class TestGeneratePaymentInfo(SavepointCase): +class TestGeneratePaymentInfo(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass()