Skip to content

[T2952] FIX: translate letter button on home page now only shows up if user is a translator#287

Merged
NoeBerdoz merged 4 commits into14.0from
T2952-translation-button-on-home
Mar 6, 2026
Merged

[T2952] FIX: translate letter button on home page now only shows up if user is a translator#287
NoeBerdoz merged 4 commits into14.0from
T2952-translation-button-on-home

Conversation

@Danielgergely
Copy link
Member

  • FEATURE: added is_translator check to my_compassion/res_partner
  • FIX: changed partner._is_volunteer check to partner._is_translator

…f user is a translator

- FEATURE: added is_translator check to my_compassion/res_partner
- FIX: changed partner._is_volunteer check to partner._is_translator
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Danielgergely, 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 refines the logic for displaying the 'translate letter' button on the user dashboard. It introduces a dedicated mechanism to identify translators, ensuring that the button is presented exclusively to users who are assigned translator roles, thereby improving the accuracy of UI element visibility based on user permissions.

Highlights

  • New is_translator field: A new computed boolean field is_translator has been added to the res.partner model to identify if a partner is a translator based on their translation_user_id.
  • Conditional button display: The 'translate letter' button on the home page dashboard now correctly uses the new is_translator field instead of is_volunteer to determine visibility, ensuring it only appears for actual translators.

🧠 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.

Changelog
  • my_compassion/models/res_partner.py
    • Added a new computed field is_translator to the Partner model.
    • Implemented the _compute_is_translator method to determine if a partner has a translation_user_id.
  • my_compassion/templates/pages/my2_dashboard.xml
    • Changed the conditional check for displaying the 'translate letter' button from partner.is_volunteer to partner.is_translator.
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

This pull request introduces a new computed field is_translator on the res.partner model to identify partners who are translators. This field is then used in the dashboard template to conditionally display a 'Translate a letter' button, ensuring it's only visible to translators. The changes are logical and correctly implement the intended feature. I have one suggestion to improve the type hinting in the new Python method for consistency with Odoo's conventions.

Compute whether the partner is a translator
"""
for partner in self:
partner.is_translator = bool(partner.translation_user_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Building a compute field on top on a compute field seems not optimal to me, also, translation_user_id is declared in another module, that is not a dependency of my_compassion, which can result in an error in some cases.

A simple trick to make the call safe here would be to do this

Suggested change
partner.is_translator = bool(partner.translation_user_id)
partner.is_translator = bool(getattr(partner, 'translation_user_id', False))

But this kind of reverse dependency is dirty.
The correct approach in my opinion would be to move this logic in my_compassion_switzerland, giving the responsibility to it to inject the Volunteer xml vignette and the logic that follows with showing the button when the volunteer is a translator.

Copy link
Member Author

Choose a reason for hiding this comment

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

@NoeBerdoz I removed the translate letter button and added it to the compassion 2025 theme. Here is the new PR: CompassionCH/compassion-switzerland#1745

# Conflicts:
#	my_compassion/templates/pages/my2_dashboard.xml
@NoeBerdoz NoeBerdoz merged commit 018a030 into 14.0 Mar 6, 2026
1 check passed
@NoeBerdoz NoeBerdoz deleted the T2952-translation-button-on-home branch March 6, 2026 13:51
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