Skip to content

Conversation

@SlWa99
Copy link
Contributor

@SlWa99 SlWa99 commented Jan 7, 2026

Criminal Record Save Failure Resolution

Purpose and Context

The goal of this PR is to fix a critical issue preventing users from updating their Criminal Record via the MyCompassion portal.

Due to Odoo security constraints and inconsistent document handling, uploads were failing when registrations were in the Attended state. In some cases, this also caused unstable registration statuses and the disappearance of events from the My Events section.

This PR should be reviewed together with a related PR, as both contribute to stabilizing the document upload and event registration workflows.


Applied Changes and Improvements

1. Portal Security and Save Reliability

  • Secure write with sudo
    Document saving in event.registration.form now uses
    form.registration_id.sudo().write(docs_to_save).

  • Result
    Documents are saved with sufficient privileges, preventing access errors, redirection crashes, and unintended status changes. The Attended status is preserved.


2. Document Management Standardization

  • Unified handling
    Passport and Criminal Record are now managed in an identical and consistent way.

  • Technical debt removal
    Complex compute / inverse logic for Passport has been removed.
    Both documents are now standard Binary fields with attachment=True on res.partner.

  • Single source of truth
    Documents are physically attached to the partner (contact).
    Event registrations access them through related fields.

  • XML cleanup
    Backend views were simplified by removing obsolete technical fields (e.g. passport_filename).


3. Validation and Testing

  • Portal upload testing
    Documents were uploaded using a real participant account for the Impact Trip in the Dominican Republic.

  • Technical verification
    Uploaded documents are visible under
    Settings → Technical → Attachments as Passport and Criminal Record.

  • Data integrity
    Each attachment correctly references the related partner in the Attached To field.


Outcome

  • Criminal Record and Passport uploads are stable and reliable.
  • Event registrations remain visible, with the Attended status preserved.
  • The codebase is cleaner, standardized, and easier to maintain.

Related PRs

This set of improvements is complemented by a related PR in the Compassion-website repository:

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @SlWa99, 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 a critical issue in the MyCompassion portal that prevented users from successfully uploading Criminal Records, particularly when event registrations were in an 'Attended' state. The changes enhance document upload security by using elevated privileges and standardize the handling of both Passport and Criminal Record documents. This leads to improved system stability, ensures event registrations remain visible, and streamlines the codebase for better maintainability.

Highlights

  • Secure Document Saving: Document saving in event.registration.form now uses form.registration_id.sudo().write(docs_to_save) to ensure sufficient privileges, preventing access errors, redirection crashes, and unintended status changes, while preserving the 'Attended' status.
  • Unified Document Handling: Passport and Criminal Record are now managed identically as standard Binary fields with attachment=True on res.partner, removing complex compute/inverse logic for Passport and simplifying backend views.
  • Centralized Document Storage: Documents are physically attached to the partner (contact) as the single source of truth, with event registrations accessing them through related fields.
  • Comprehensive Testing: Portal upload testing was performed using a real participant account, and technical verification confirmed uploaded documents are visible under Settings → Technical → Attachments with correct partner references.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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
Contributor

@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

The pull request aims to resolve an issue with uploading criminal records by standardizing document handling for both passports and criminal records. The changes in child_protection/models/partner_compassion.py add new fields for passport data, mirroring the existing structure for other documents, which is a good step for consistency. However, this approach also continues a pattern of code duplication in the compute methods for document names. My review provides a suggestion to refactor this duplicated logic to enhance long-term maintainability. Overall, the changes are logical and contribute to the stated goal of the pull request.

@ecino
Copy link
Member

ecino commented Jan 15, 2026

While I agree with the changes, I think you put the fields in the wrong module. Why not including those directly in the module which is using them ? Please move those fields in this module from your other pull request and we can close this one.

@ecino ecino closed this Jan 15, 2026
@SlWa99
Copy link
Contributor Author

SlWa99 commented Jan 15, 2026

Ok, it's normally done !

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.

3 participants