Skip to content

Commit

Permalink
[REF] l10n_br_nfe: adapt to simpler hook
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalyi committed Sep 2, 2024
1 parent 997447f commit 3f95e35
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 30 deletions.
7 changes: 1 addition & 6 deletions l10n_br_nfe/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@
from odoo import SUPERUSER_ID, api
from odoo.exceptions import ValidationError

from odoo.addons.spec_driven_model import hooks

_logger = logging.getLogger(__name__)


def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
hooks.register_hook(
env, "l10n_br_nfe", "odoo.addons.l10n_br_nfe_spec.models.v4_0.leiaute_nfe_v4_00"
)

env["nfe.40.infnfe"]._register_hook()
cr.execute("select demo from ir_module_module where name='l10n_br_nfe';")
is_demo = cr.fetchone()[0]
if is_demo:
Expand Down
17 changes: 5 additions & 12 deletions l10n_br_nfe/tests/test_nfe_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@
from odoo.models import NewId
from odoo.tests import SavepointCase

from odoo.addons.spec_driven_model import hooks

_logger = logging.getLogger(__name__)


class NFeImportTest(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env["spec.mixin.nfe"]._register_hook()

def test_import_in_nfe_dry_run(self):
hooks.register_hook(
self.env,
"l10n_br_nfe",
"odoo.addons.l10n_br_nfe_spec.models.v4_0.leiaute_nfe_v4_00",
)
res_items = (
"nfe",
"samples",
Expand All @@ -40,11 +38,6 @@ def test_import_in_nfe_dry_run(self):
self._check_nfe(nfe)

def test_import_in_nfe(self):
hooks.register_hook(
self.env,
"l10n_br_nfe",
"odoo.addons.l10n_br_nfe_spec.models.v4_0.leiaute_nfe_v4_00",
)
res_items = (
"nfe",
"samples",
Expand Down
7 changes: 1 addition & 6 deletions l10n_br_nfe/tests/test_nfe_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@
from odoo.tools import config

from odoo.addons import l10n_br_nfe
from odoo.addons.spec_driven_model import hooks

_logger = logging.getLogger(__name__)


class TestNFeExport(TransactionCase):
def setUp(self, nfe_list):
super().setUp()
hooks.register_hook(
self.env,
"l10n_br_nfe",
"odoo.addons.l10n_br_nfe_spec.models.v4_0.leiaute_nfe_v4_00",
)
self.env["spec.mixin.nfe"]._register_hook()
self.nfe_list = nfe_list
for nfe_data in self.nfe_list:
nfe = self.env.ref(nfe_data["record_ref"])
Expand Down
7 changes: 1 addition & 6 deletions l10n_br_nfe/tests/test_nfe_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from odoo.tests import SavepointCase

from odoo.addons.spec_driven_model import hooks
from odoo.addons.spec_driven_model.models.spec_models import SpecModel

from ..models.document import NFe
Expand All @@ -17,11 +16,7 @@ class NFeStructure(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
hooks.register_hook(
cls.env,
"l10n_br_nfe",
"odoo.addons.l10n_br_nfe_spec.models.v4_0.leiaute_nfe_v4_00",
)
cls.env["spec.mixin.nfe"]._register_hook()

@classmethod
def get_stacked_tree(cls, klass):
Expand Down

0 comments on commit 3f95e35

Please sign in to comment.