EMS

Technical Reference: form “Actions” dropdown

A form’s actions on the record it shows live in one “Actions” dropdown button in the header, never as loose header buttons. Each entry is still an ordinary form button, so it keeps its own invisible=, groups= and confirm=: the dropdown only lists what applies to this record and this user, and it isn’t rendered at all when nothing does. When exactly one entry applies, it is shown as that plain header button instead of a dropdown (issue #639): a dropdown hiding a single action only makes it harder to find, and a notice was left in draft because its teacher never saw the “Send now” inside it.

It exists because neither native option covers the three needs at once:

  Hidden per record state / per-user relationship Visible to users Header stays short
Native ⚙ cog menu (binding_model_id actions) No: get_bindings() filters by groups_id and model read access only, never per record No: users don’t find it Yes
Loose header buttons Yes Yes No
Actions dropdown Yes Yes Yes

Used on the contact form (views/community/contact/form.xml), the employee form (views/community/employee/form.xml), the convalidation request form (views/academic_management/convalidations/views.xml), the notice form (views/communications/notice/form.xml) and the student document form (views/community/contact/student_document.xml); nothing in it is specific to any model.

Usage

Put the buttons inside a <div name="ems_actions" string="..."> directly under <header>:

<header>
    <div name="ems_actions" string="Actions">
        <button name="action_reset_google_password" type="object" string="Reset Google password"
                invisible="google_ws_state != 'active' or not can_reset_google_password"
                confirm="..." groups="ems.group_academic_admin,ems.group_tac,ems.group_tutor"/>
        ...
    </div>
</header>

Rules:

How it works

static/src/js/backend/actions_dropdown.js + static/src/xml/backend/actions_dropdown.xml:

Testing

static/tests/tours/actions_dropdown_helpers.js holds the tour steps every tour needs to reach the entries: they only exist while the dropdown is open, and the open menu is rendered in the overlay container, outside .o_form_view. So a plain .o_form_view button[name=...] trigger never finds an entry, and a :not(:has(button[name=...])) check on the form passes whether it is offered or not.

tests/test_actions_dropdown_tour.py covers the component itself: as a tutor, which entries a real render offers for one of their students, that no button is left loose in the header, and that a family contact gets no dropdown; as an administrator on an employee with extra hours, that EMS’s entries and the native “Deduct Extra Hours” share the one dropdown with nothing loose in the header. tests/test_notice_tour.py covers the single-entry case: a draft notice’s only action, “Send now”, is a highlighted header button with no dropdown.

Lists

A list’s header buttons (the ones shown once records are selected) get the same “Actions” dropdown, instead of a row of loose buttons next to the selection: same look, same reasons. Odoo’s own ⚙ menu next to it keeps the actions bound to the model (export, delete, server actions).