-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[19.0][FIX] fordward port of missing commits #3729
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
Open
sergio-teruel
wants to merge
8
commits into
OCA:19.0
Choose a base branch
from
Tecnativa:19.0-fwp-base_exception-rollback-and-fixes
base: 19.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c481946
[FIX] base_exception: Rollback transaction if we detect exceptions
grindtildeath 0585624
[REF] base_exception: Handle the exception popup at client level
grindtildeath fd9116e
[REF] base_exception: Use a client action to reload smoothly
grindtildeath 1e71842
[TEST] base_exception: Test exception rollbacking
grindtildeath afd3d2f
base_exception: no second cursor when installing modules
florian-dacosta 696561e
[FIX] base_exception: MissingError on records created in the ongoing …
sergio-teruel 5181008
[FIX] base_exception: declare decorator as external python dependency
sergio-teruel 0f939e6
[FIX] base_exception: use 19.0's registry_enter_test_mode API
sergio-teruel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Copyright 2025 Camptocamp SA | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
|
|
||
| from odoo.exceptions import UserError | ||
|
|
||
|
|
||
| class BaseExceptionError(UserError): | ||
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import {registry} from "@web/core/registry"; | ||
|
|
||
| /* eslint-disable no-unused-vars */ | ||
| async function popUpException(env, _action) { | ||
| /* eslint-enable no-unused-vars */ | ||
| const controller = env.services.action.currentController; | ||
| const orm = env.services.orm; | ||
| const resId = controller.currentState?.resId; | ||
| const resModel = controller.props.resModel; | ||
| if (!resModel || !resId) return; | ||
| const popupAction = await orm.call(resModel, "action_popup_exceptions", [[resId]]); | ||
| if (!popupAction) return; | ||
| // Do a soft reload before displaying the popup to display the exception | ||
| // on the Form view | ||
| await env.services.action.restore(controller.jsId); | ||
| await env.services.action.doAction(popupAction); | ||
| } | ||
|
|
||
| function baseExceptionErrorHandler(env, uncaughtError, originalError) { | ||
| const controller = env.services.action.currentController; | ||
| if ( | ||
| originalError.exceptionName === | ||
| "odoo.addons.base_exception.exceptions.BaseExceptionError" | ||
| ) { | ||
| const excData = JSON.parse(originalError.data.message); | ||
| if (excData.target_model === controller.props.resModel) { | ||
| env.services.action.doAction({ | ||
| type: "ir.actions.client", | ||
| tag: "popup_exception", | ||
| }); | ||
| } else { | ||
| env.services.action.doAction({ | ||
| type: "ir.actions.client", | ||
| tag: "soft_reload", | ||
| }); | ||
| } | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| registry.category("actions").add("popup_exception", popUpException); | ||
| registry | ||
| .category("error_handlers") | ||
| .add("base_exception_error", baseExceptionErrorHandler, {sequence: 0}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Copyright 2026 Camptocamp SA | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
|
|
||
| try: | ||
| from decorator import decoratorx as decorator | ||
| except ImportError: | ||
| from decorator import decorator | ||
|
|
||
| from contextlib import contextmanager | ||
| from unittest.mock import patch | ||
|
|
||
| from ..exceptions import BaseExceptionError | ||
|
|
||
|
|
||
| @decorator | ||
| def swallow_base_exception_error(func, self): | ||
| def wrapper(*args, **kwargs): | ||
| try: | ||
| return func(*args, **kwargs) | ||
| except BaseExceptionError: | ||
| return None | ||
|
|
||
| return wrapper | ||
|
|
||
|
|
||
| @contextmanager | ||
| def mock_base_exception_method_env(self, env=None): | ||
| if env is None: | ||
| env = self.env | ||
| with patch( | ||
| "odoo.addons.base_exception.models.base_exception_method.Environment" | ||
| ) as mocked_env: | ||
| mocked_env.return_value = env | ||
| yield | ||
|
|
||
|
|
||
| @decorator | ||
| def patch_base_exception_method_env(func, self): | ||
| with mock_base_exception_method_env(self): | ||
| return func(self) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you adapt the code as commented here: https://github.com/OCA/server-tools/pull/3729/changes#r4036710316 please remove the TODO.