Skip to content

Conversation

@emjay0921
Copy link
Contributor

Why is this change needed?

Clicking a program membership row in the registrant form (res.partner) was opening the spp.program.membership form instead of the program form. Users expect to see the program details when clicking a membership entry.

How was the change implemented?

Extended the ListRenderer.onCellClicked patch in custom_open_list.js to also handle spp.program.membership rows:

  • Extracts program_id from the membership record data
  • Calls open_program_form with the program ID
  • Opens the program form in a modal (target: "new") to keep the registrant context

New unit tests

Unit tests executed by the author

How to test manually

  1. Open a registrant (individual or group) form
  2. Scroll to the "Program Enrollments" section
  3. Click on a program membership row
  4. Verify the program form opens in a modal dialog (not navigating away)

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 enhances the user experience within the registrant form by ensuring that clicking on a program membership entry consistently opens the relevant program details in a new modal window. This resolves an issue where the incorrect form was displayed, streamlining the workflow for users needing to view program information directly from a registrant's enrollment list.

Highlights

  • Corrected Program Form Opening: Clicking a program membership row in the registrant form now correctly opens the associated program details form instead of the membership form.
  • Modal Display for Program Forms: The program form, when opened from a membership row, now appears in a modal dialog, preserving the registrant context and preventing navigation away from the current view.
  • Extended List Renderer Patch: The onCellClicked method in custom_open_list.js was extended to specifically handle spp.program.membership records, extracting the correct program_id.
Changelog
  • spp_programs/static/src/js/custom_open_list.js
    • Extended the onCellClicked method to recognize spp.program.membership records.
    • Implemented logic to extract the program_id from spp.program.membership data.
    • Configured the program form to open in a new modal (action.target = "new") when triggered from a membership row.
Activity
  • New unit tests were added by the author.
  • Unit tests were executed by the author.
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 correctly identifies the need to change the click behavior on program membership rows for a better user experience. The approach of patching ListRenderer.onCellClicked is appropriate. However, the implementation contains a critical bug in how it retrieves the program_id from the membership record, which prevents the feature from working as intended. I've provided a fix for this. Additionally, there's a minor suggestion to improve code style consistency. Once these points are addressed, the change should work as expected.

Comment on lines +36 to +40
if (programField && programField.id) {
programId = programField.id;
} else {
return super.onCellClicked(record, column, ev);
}

Choose a reason for hiding this comment

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

critical

The logic to retrieve the program ID from a spp.program.membership record is incorrect. In Odoo's OWL framework, a Many2one field like program_id is represented in record.data as an array [id, displayName], not an object with an id property. The current check programField.id will always be falsy, causing the function to fall back to the default behavior and not open the program form as intended.

Suggested change
if (programField && programField.id) {
programId = programField.id;
} else {
return super.onCellClicked(record, column, ev);
}
if (programField && programField.length) {
programId = programField[0];
} else {
return super.onCellClicked(record, column, ev);
}

Comment on lines +44 to +46
var action = await this.orm.call("spp.program", "open_program_form", [
programId,
]);

Choose a reason for hiding this comment

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

medium

For consistency with modern JavaScript practices and the surrounding code, it's better to use const or let instead of var. Since the action variable is not reassigned, const is the most appropriate choice here.

Suggested change
var action = await this.orm.call("spp.program", "open_program_form", [
programId,
]);
const action = await this.orm.call("spp.program", "open_program_form", [
programId,
]);

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