-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[18.0][FIX] base_exception: Rollback transaction if we detect exceptions #3590
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
base: 18.0
Are you sure you want to change the base?
Changes from 9 commits
61eed8a
9a1c94c
08266fe
e1b81f8
1a2e3c6
9857533
c008459
e9c8a9d
c548c60
190597f
20a2885
c309ca0
f1b8586
78412ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import {patch} from "@web/core/utils/patch"; | ||
| import {registry} from "@web/core/registry"; | ||
| import {rpc} from "@web/core/network/rpc"; | ||
|
|
||
| /* 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); | ||
| } | ||
|
|
||
| patch(rpc, { | ||
| async _rpc(url, params = {}, settings = {}) { | ||
| try { | ||
| return await super._rpc(url, params, settings); | ||
| } catch (error) { | ||
| if ( | ||
| error.exceptionName === | ||
| "odoo.addons.base_exception.exceptions.BaseExceptionError" | ||
| ) { | ||
| if (error.data.message.split(":")[1].trim() === params.model) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I get it right when looking at If you register the exception into any of these registries, you won't need this patch: The second one is probably the right one. Not a blocker but maybe we can add a TODO here 😉
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in fixup commit, but had to use |
||
| return {type: "ir.actions.client", tag: "popup_exception"}; | ||
| } | ||
| return {type: "ir.actions.client", tag: "soft_reload"}; | ||
| } | ||
| throw error; | ||
| } | ||
| }, | ||
| }); | ||
|
|
||
| registry.category("actions").add("popup_exception", popUpException); | ||
Uh oh!
There was an error while loading. Please reload this page.