Skip to content

Commit

Permalink
Merge PR #482 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by lmignon
  • Loading branch information
OCA-git-bot committed Jan 6, 2025
2 parents c89c938 + 0a48b5d commit 9c999ec
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion extendable/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from odoo import api
from odoo.tests import common

from extendable import context
from extendable import context, main


def _get_addon_name(full_name: str) -> str:
Expand Down Expand Up @@ -53,6 +53,24 @@ def init_extendable_registry(cls):
extendable_registry.init_registry([f"odoo.addons.{current_addon}.*"])
cls.token = context.extendable_registry.set(cls._extendable_registry)

@classmethod
def backup_extendable_registry(cls):
# Store the current extendable classes
cls._initial_extendable_class_defs_by_module = (
main._extendable_class_defs_by_module
)
# Use a copy of the current extendable classes
main._extendable_class_defs_by_module = dict(
cls._initial_extendable_class_defs_by_module
)

@classmethod
def restore_extendable_registry(cls):
# Restore the initial extendable classes
main._extendable_class_defs_by_module = (
cls._initial_extendable_class_defs_by_module
)

@classmethod
def reset_extendable_registry(cls):
context.extendable_registry.reset(cls.token)

0 comments on commit 9c999ec

Please sign in to comment.