Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions spp_programs/static/src/js/custom_open_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ patch(ListRenderer.prototype, {
},

async onCellClicked(record, column, ev) {
if (record.resModel === "spp.program") {
if (
record.resModel === "spp.program" ||
record.resModel === "spp.program.membership"
) {
// Skip custom behavior if in selection mode (e.g., Many2one "Search More..." dialog)
// In selection mode, don't open form - let dialog handle row selection
const isSelectionMode =
Expand All @@ -26,10 +29,24 @@ patch(ListRenderer.prototype, {
// In selection mode, use default behavior which handles selection
return super.onCellClicked(record, column, ev);
}

let programId = record.resId;
if (record.resModel === "spp.program.membership") {
const programField = record.data.program_id;
if (programField && programField.id) {
programId = programField.id;
} else {
return super.onCellClicked(record, column, ev);
}
Comment on lines +36 to +40
Copy link
Copy Markdown

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

}

// Get the stored action from the server (includes action id for proper routing)
var action = await this.orm.call("spp.program", "open_program_form", [
record.resId,
programId,
]);
if (record.resModel === "spp.program.membership") {
action.target = "new";
}
this.actionService.doAction(action);
} else {
super.onCellClicked(record, column, ev);
Expand Down
Loading