Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][REF][l10n_br_account_nfe] lint #3269

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions l10n_br_account_nfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,15 @@ def _check_fiscal_payment_mode(self):
if not rec.move_ids.payment_mode_id.fiscal_payment_mode:
raise UserError(
_(
f"Payment Mode {rec.move_ids.payment_mode_id.name} should has "
"has Fiscal Payment Mode filled to be used in Fiscal Document!"
"Payment Mode %(mode)s should have "
"a Fiscal Payment Mode filled to be used in the Fiscal Document!",
mode=rec.move_ids.payment_mode_id.name,
)
)

def _update_nfce_for_offline_contingency(self):
super()._update_nfce_for_offline_contingency()

res = super()._update_nfce_for_offline_contingency()
if self.move_ids:
copy_invoice = self.move_ids[0].copy()
copy_invoice.action_post()
return res
12 changes: 9 additions & 3 deletions l10n_br_account_nfe/tests/test_nfce_contingency.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@

from odoo.tests import TransactionCase

from odoo.addons.spec_driven_model import hooks

class TestAccountNFCe(TransactionCase):

class TestAccountNFCeContingency(TransactionCase):
def setUp(self):
super().setUp()

# this hook is required to test l10n_br_account_nfe alone:
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()

Expand Down Expand Up @@ -64,5 +71,4 @@ def prepare_account_move_nfce(self):

def test_nfce_contingencia(self):
self.document_id._update_nfce_for_offline_contingency()

self.assertIn(self.document_move_id, self.document_id.move_ids)
2 changes: 1 addition & 1 deletion l10n_br_account_nfe/tests/test_nfe_danfe_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


@tagged("post_install", "-at_install")
class TestGeneratePaymentInfo(SavepointCase):
class TestDanfe(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
10 changes: 8 additions & 2 deletions l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def setUpClass(cls):
check_move_validity=False
)._onchange_fiscal_operation_line_id()
line.with_context(check_move_validity=False)._onchange_fiscal_tax_ids()
cls.invoice_demo_data.action_post()

def test_nfe_generate_tag_pag(self):
"""Test NFe generate TAG PAG."""
Expand Down Expand Up @@ -192,8 +191,15 @@ def test_payment_mode_without_fiscal_mode(self):
}
)
self.invoice_demo_data.payment_mode_id = self.pay_mode.id
with self.assertRaises(UserError):
with self.assertRaises(UserError) as captured_exception:
self.invoice_demo_data.action_post()
self.assertEqual(
captured_exception.exception.args[0],
(
"Payment Mode Sem Meio Fiscal should have a "
"Fiscal Payment Mode filled to be used in the Fiscal Document!"
),
)

def test_invoice_without_payment_mode(self):
"""Test Invoice without Payment Mode."""
Expand Down
4 changes: 2 additions & 2 deletions l10n_br_account_nfe/tests/test_nfe_with_ipi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


@tagged("post_install", "-at_install")
class TestAccountAccount(AccountMoveBRCommon):
class TestNFeWithIPI(AccountMoveBRCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref)
Expand Down Expand Up @@ -35,7 +35,7 @@ def setUpClass(cls, chart_template_ref=None):
post=False,
)
cls.move_out_venda.payment_mode_id = cls.payment_mode
cls.move_out_venda.post()
cls.move_out_venda.action_post()

def test_nfe_with_ipi(self):
"""
Expand Down
Loading