fix(spp_programs): reliably close wizard modal after program creation#15
fix(spp_programs): reliably close wizard modal after program creation#15
Conversation
Summary of ChangesHello @emjay0921, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an intermittent user experience issue where the program creation wizard modal would sometimes fail to close after a program was successfully created. By introducing an asynchronous client-side action, the system now guarantees that the modal is dismissed before the user is redirected to the new program's details, providing a smoother and more predictable workflow. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses an intermittent bug where the program creation wizard modal would not close reliably. The solution, which involves a new JavaScript client action using async/await to sequence the modal closing and navigation, is well-implemented. The related Python code has been refactored to use ensure_one() and return the new client action, which is a good improvement. All tests have been updated accordingly. I have a couple of suggestions to improve the new client action by making it more flexible and translatable, restoring some of the functionality from the previous implementation.
| const actionService = env.services.action; | ||
| const programId = action.params?.program_id; | ||
|
|
||
| // First close the modal | ||
| await actionService.doAction( | ||
| {type: "ir.actions.act_window_close"}, | ||
| {clearBreadcrumbs: true} | ||
| ); | ||
|
|
||
| // Then open the program form | ||
| if (programId) { | ||
| await actionService.doAction({ | ||
| type: "ir.actions.act_window", | ||
| name: "Program", | ||
| res_model: "spp.program", | ||
| res_id: programId, | ||
| views: [[false, "form"]], | ||
| target: "current", | ||
| }); | ||
| } |
There was a problem hiding this comment.
The name of the action window is hardcoded as "Program", which isn't translatable. Also, the views parameter is hardcoded to use the default form view ([[false, "form"]]), which differs from the previous implementation that allowed a specific view_id to be used. To improve internationalization and restore the original flexibility, consider passing the name and view_id from the server-side action's parameters.
const actionService = env.services.action;
const programId = action.params?.program_id;
const programName = action.params?.name || "Program";
const viewId = action.params?.view_id || false;
// First close the modal
await actionService.doAction(
{type: "ir.actions.act_window_close"},
{clearBreadcrumbs: true}
);
// Then open the program form
if (programId) {
await actionService.doAction({
type: "ir.actions.act_window",
name: programName,
res_model: "spp.program",
res_id: programId,
views: [[viewId, "form"]],
target: "current",
});
}| "params": { | ||
| "program_id": program_id, | ||
| }, |
There was a problem hiding this comment.
To support internationalization and allow for specific form views, it's a good practice to pass the translated window name and the calculated view_id to the client action. The JavaScript action can then use these parameters instead of hardcoded values.
"params": {
"program_id": program_id,
"name": _("Program"),
"view_id": view_id.id,
},
Why is this change needed?
The wizard modal intermittently stayed open after program creation. The old approach returned
ir.actions.act_windowdirectly from the wizard, which didn't reliably close the modal before navigating to the program form.Also hides the Geographic Targeting section from the Eligibility Manager UI and Create Program wizard.
How was the change implemented?
ensure_one()and removed unnecessaryfor rec in self:loop increate_program()open_program_close_modal) using async/await to properly sequence: close the modal first, then navigate to the program formir.actions.act_windowtoir.actions.clientaction["params"]["program_id"]instead ofaction["res_id"]invisible="1"to Geographic Targeting group in eligibility manager view and create program wizardNew unit tests
No new tests — existing tests were updated to match the new return format.
Unit tests executed by the author
All 169 spp_programs tests pass (0 failed, 0 errors).
How to test manually
Related links