[FIX] base_ux: keep quick activity badges when editing an activity#428
Open
zaoral wants to merge 1 commit into
Open
[FIX] base_ux: keep quick activity badges when editing an activity#428zaoral wants to merge 1 commit into
zaoral wants to merge 1 commit into
Conversation
The quick badges customization was only applied to the mail.activity.schedule wizard, used when scheduling a new activity. Editing an existing activity opens an act_window on mail.activity instead (view mail_activity_view_form_popup), so that dialog kept rendering a badge for every activity type in the system. Inherit that view with the same treatment and share the lookup of the suggested types through mail.activity.type._get_quick_activity_types(). On mail.activity the computed field also includes the type currently set on the record: without it, editing an activity whose type is not among the suggested ones would not render the stored value at all.
Contributor
There was a problem hiding this comment.
Pull request overview
Este PR corrige una inconsistencia de UX en base_ux para que el popup de edición de mail.activity use el mismo esquema de “badges rápidos + selector buscable” que ya existía en el wizard de creación, evitando mostrar decenas de badges cuando hay muchos tipos de actividad.
Changes:
- Se hereda la vista popup de
mail.activitypara limitar badges a los “quick types” y agregar un selector alternativo. - Se centraliza el cálculo de tipos sugeridos en
mail.activity.type._get_quick_activity_types()y se reutiliza desde wizard y actividad. - Se agrega cobertura de tests para límite por parámetro, wizard y edición preservando el tipo actual.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| base_ux/views/mail_activity_view.xml | Hereda el popup de mail.activity para aplicar el mismo comportamiento de quick badges que el wizard. |
| base_ux/models/mail_activity.py | Agrega quick_activity_ids computado en mail.activity e incluye el tipo actual al editar. |
| base_ux/models/mail_activity_type.py | Introduce helper compartido _get_quick_activity_types() para obtener los tipos rápidos desde parámetro. |
| base_ux/models/mail_activity_schedule.py | Reutiliza _get_quick_activity_types() en lugar de duplicar lectura/casteo del parámetro. |
| base_ux/tests/test_mail_activity_quick_badges.py | Tests nuevos para los tres casos descritos en el plan de pruebas. |
| base_ux/tests/init.py | Incluye el nuevo archivo de tests en el paquete. |
| base_ux/models/init.py | Registra el nuevo modelo heredado mail_activity_type. |
| base_ux/README.rst | Actualiza la descripción del comportamiento/configuración de quick badges. |
| base_ux/manifest.py | Agrega la nueva vista al manifest para que se cargue en el módulo. |
Comment on lines
+16
to
+17
| limit_param = self.env["ir.config_parameter"].sudo().get_param("base_ux.activity_quick_badges", "5") | ||
| return self.search([], order="sequence, id", limit=int(limit_param)) |
Comment on lines
+5
to
+9
| from odoo.tests import TransactionCase | ||
|
|
||
|
|
||
| class TestMailActivityQuickBadges(TransactionCase): | ||
| @classmethod |
| * Keep the activity's description when changing the activity type, regardless of the activity type's description, and change the activity user only if the activity type has a default user. | ||
| * Make company_registry field on res.company invisible as it is useless now | ||
| * Show or hide the activity badge widget depending on the number of activity types defined in the system (configurable threshold, default to 5). | ||
| * On the "Schedule Activity" dialog, show only the first N activity types (ordered by sequence) as quick badges, plus a dropdown to search among all the remaining ones. It applies both when scheduling a new activity and when editing an existing one; on an existing activity its current type is always kept among the badges. N is set through the system parameter base_ux.activity_quick_badges (default to 5). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The quick activity badges customization was only applied to the creation flow, so the two dialogs behaved differently:
mail.activity.schedulewizard, whose view is already inherited inviews/mail_activity_schedule_view.xmlto limit theselection_badge_iconswidget to the first N types and to offer a dropdown for the rest.act_windowonmail.activity(viewmail.mail_activity_view_form_popup), which was not inherited at all. That dialog rendered a badge for every activity type in the system, which is unusable on a database with dozens of them.Both dialogs are titled "Schedule Activity", which makes the difference easy to miss.
Changes
views/mail_activity_view.xmlinheritingmail.mail_activity_view_form_popupwith the same domain on the badges widget plus the searchable fallback field. It also reachesmail.mail_activity_view_form(the full page view), which inherits from the popup one.mail.activity.type._get_quick_activity_types(), shared by both models instead of duplicating the parameter handling.mail.activitythe computed field also includes the type currently set on the record. Without it, editing an activity whose type is not among the suggested ones would render no badge for the stored value.No behaviour change on the creation wizard.
Test plan
New
tests/test_mail_activity_quick_badges.pycovers the three cases (parameter limit, wizard unchanged, existing activity keeping its own type). Run:Manually: on a database with more activity types than the configured limit (
base_ux.activity_quick_badges, default 5), schedule an activity, save it, then hit Edit on it. Both dialogs must show the same short list of badges plus the search dropdown.