Skip to content

fix(spp_programs): reliably close wizard modal after program creation#15

Open
emjay0921 wants to merge 3 commits into19.0from
fix/spp-programs-wizard-modal-close
Open

fix(spp_programs): reliably close wizard modal after program creation#15
emjay0921 wants to merge 3 commits into19.0from
fix/spp-programs-wizard-modal-close

Conversation

@emjay0921
Copy link
Contributor

@emjay0921 emjay0921 commented Feb 6, 2026

Why is this change needed?

The wizard modal intermittently stayed open after program creation. The old approach returned ir.actions.act_window directly 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?

  • Added ensure_one() and removed unnecessary for rec in self: loop in create_program()
  • Created a JS client action (open_program_close_modal) using async/await to properly sequence: close the modal first, then navigate to the program form
  • Changed return type from ir.actions.act_window to ir.actions.client
  • Updated all callers (compliance wizard, CEL wizard) and tests to use action["params"]["program_id"] instead of action["res_id"]
  • Added invisible="1" to Geographic Targeting group in eligibility manager view and create program wizard

New 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

  1. Open Programs list view
  2. Click "Create Program" button
  3. Fill in the wizard and click Create
  4. Verify the modal closes and you're navigated to the new program form
  5. Open an Eligibility Manager — Geographic Targeting section should not be visible

Related links

@gemini-code-assist
Copy link

Summary of Changes

Hello @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

  • Reliable Modal Closure: The primary change introduces a new asynchronous JavaScript client action, openProgramCloseModal, to ensure that the wizard modal is reliably closed before navigating to the newly created program's form. This resolves an intermittent issue where the modal would remain open.
  • Refactored Program Creation Logic: The create_program method in create_program_wizard.py has been refactored to include self.ensure_one() and remove an unnecessary for-loop, simplifying the code and ensuring it operates on a single record.
  • Updated Action Return Type: The create_program method now returns an ir.actions.client action with a custom tag (open_program_close_modal) and the program_id embedded in its params, instead of the previous ir.actions.act_window.
  • Caller and Test Adaptations: All relevant callers, including compliance and CEL wizards, and associated test files, have been updated to correctly interpret the new action return format, specifically accessing program_id from action["params"]["program_id"].
Changelog
  • spp_programs/static/src/js/create_program.js
    • Added a new asynchronous JavaScript function openProgramCloseModal to handle the sequential closing of the modal and opening of the program form.
    • Registered openProgramCloseModal as a client action with the tag open_program_close_modal.
  • spp_programs/tests/test_create_program_wiz.py
    • Updated test assertions to reflect the new return type of create_program (from ir.actions.act_window to ir.actions.client).
    • Modified tests to access the program ID via action["params"]["program_id"] instead of action["res_id"].
  • spp_programs/tests/test_spp_cycle_compliance.py
    • Adjusted program ID retrieval from action["res_id"] to action["params"]["program_id"].
  • spp_programs/tests/test_spp_program_create_wizard_compliance.py
    • Updated program ID retrieval from action["res_id"] to action["params"]["program_id"].
  • spp_programs/wizard/create_program_wizard.py
    • Added self.ensure_one() to the create_program method.
    • Removed an unnecessary for rec in self: loop from create_program.
    • Changed the return value of create_program to an ir.actions.client dictionary, specifying open_program_close_modal as the tag and passing program_id in params.
  • spp_programs/wizard/create_program_wizard_cel.py
    • Modified program ID retrieval from action["res_id"] to action["params"]["program_id"].
  • spp_programs/wizard/create_program_wizard_compliance.py
    • Updated program ID retrieval from action["res_id"] to action["params"]["program_id"].
Activity
  • The pull request was authored by emjay0921.
  • The changes are a port of commit 7ef794b from openspp-modules-v2.
  • All 169 spp_programs tests passed, indicating no regressions were introduced.
  • The fix addresses an intermittent issue where the wizard modal would remain open after program creation.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 15 to 34
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",
});
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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",
        });
    }

Comment on lines 430 to 432
"params": {
"program_id": program_id,
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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,
            },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant