Skip to content

Conversation

@SlWa99
Copy link

@SlWa99 SlWa99 commented Jan 15, 2026

Activation of Backend Manual Sorting for Volunteering Opportunities and Donations

Description

Context and Problem

Currently, on the MyCompassion website, the display order of frontend components for volunteering opportunities (advocate.engagement) and donations (product.template) relies on the default database order.
There is no mechanism allowing administrators to define a custom display priority through the Odoo backend.


Solution

This PR enables a dynamic and configurable manual sorting system managed directly from the backend via drag-and-drop (handle widget).
The order defined by administrators is strictly respected on the MyCompassion website.

Backend configuration locations:

  • product.template : Module Sales, tab Products → Products
  • advocate.engagement : Module Sponsorship, tab Advocates → Engagement Types

Functional Note

A page refresh (F5) is required on the website to reflect ordering changes.
The frontend is not reactive in real time and displays the database state at page load (see technical implementation details below).


Technical Implementation

The approach differs depending on the model to ensure system stability.


1. advocate.engagement

All required sorting infrastructure already existed in the codebase.

  • Model

    • sequence field already defined
    • _order attribute already configured
  • View

    • Drag-and-drop handle widget already present in the list view

Result
The sorting mechanism works natively with no additional changes required for this model.


2. product.template

This model has a default Odoo ordering that overrides manual sorting when the backend page is refreshed.
To enable manual sorting without impacting other Odoo applications (e.g. Sales), the following approach was implemented:

  • Model (product_template.py)

    • No changes were made to _order or the sequence field to avoid side effects in other modules.
  • View (product_view.xml)

    • The standard list view product.product_template_tree_view is inherited.
    • Injection of the following attribute:
      <attribute name="default_order">sequence, default_code, name</attribute>
    • This forces the backend interface to respect the sequence order when loading the page.
  • Controller (my2_gifts.py)

    • On each page load, the controller fetches data again from the database using manual ordering before rendering the template.
    • This explains why a page refresh is required to see ordering changes.
# Controller fetches manually ordered data on each request
my_compassion_gifts = request.env["product.template"].search(
    domain,
    order='sequence'  # Enforces backend-defined manual ordering
)

# Data is then passed to the rendering engine
return request.render(
    "my_compassion.my2_gifts_page",
    {
        "my_compassion_gifts": my_compassion_gifts,
        "type": type,
    },
)

Results

  • The order defined in the backend is correctly reflected on the MyCompassion website (Gift and Volunteer pages) after a page refresh.
  • The order is preserved after:
    • Reloading the backend configuration page
    • Restarting the application or server

Test Scenarios

Scenario 1: Custom Random Order

  • Backend configuration: custom order defined via drag-and-drop
eng_conf1
  • Frontend rendering: order matches backend configuration after page refresh
eng_mc1

Scenario 2: Order Modification

  • Backend configuration (after drag & drop): updated order
eng_conf2
  • Frontend rendering (after page refresh): updated order correctly reflected
eng_mc2

@gemini-code-assist
Copy link

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 introduces a crucial feature for MyCompassion administrators, enabling them to manually control the display order of volunteering opportunities and donation products on the frontend. By integrating a drag-and-drop sorting mechanism within the Odoo backend, this change provides greater flexibility and customization for content presentation, ensuring that the most relevant items can be prioritized.

Highlights

  • Manual Sorting for Frontend Components: Implemented a dynamic, drag-and-drop manual sorting system in the Odoo backend for advocate.engagement (volunteering opportunities) and product.template (donations).
  • Advocate Engagement Integration: The advocate.engagement model natively supported manual sorting due to existing sequence field and _order attribute, requiring no code changes.
  • Product Template Specific Implementation: For product.template, the standard Odoo ordering was overridden by inheriting the list view (product.product_template_tree_view) to enforce sequence as the default order in the backend.
  • Frontend Data Fetching: The my2_gifts controller was updated to explicitly fetch product.template data ordered by sequence, ensuring the frontend reflects the manual sorting.
  • Page Refresh Requirement: A page refresh (F5) is required on the MyCompassion website for ordering changes to become visible, as the frontend is not reactive in real-time.

🧠 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

@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 introduces a manual sorting capability for donation products, which is a great enhancement for content managers. The implementation is well-thought-out, especially the approach for product.template which avoids modifying the base model's _order to prevent side effects. I have a couple of suggestions to improve the stability of the sorting and the clarity of the code.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

2 participants