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.
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:
div.div in the form’s own <header> (//header position="inside") when the inherited form already has one, rather than adding a second <header>: a form has one status bar.<xpath ... position="move"/> nested in an xpath on the div. The moving view must run after the one that adds the button: view_employee_form_native_actions has priority 130 because hr_holidays_attendance adds “Deduct Extra Hours” at 120, and hr_holidays_attendance is in EMS’s depends so it is loaded first on a clean install. Match the button on an attribute that is neither translated (string) nor an action id resolved at load time (name="%(xmlid)d"), e.g. its context. A native button that is hidden for good (invisible="1", like the employee’s “Launch Plan”) can stay where it is.type="object", not type="action", to run a bulk method on this one record. A form button of type="action" sends active_ids = the record’s resIds, which can be the whole pager list rather than the record on screen. The bulk methods (res.partner.action_portal_access_bulk() etc.) already work on any recordset, a single record included.@api.depends_context('uid') read by the entry’s invisible= (e.g. can_reset_google_password, can_download_google_credentials), and the method re-checks them server-side. groups= alone only says the user holds a role, not that the role applies to this record.binding_view_types = list), since there it acts on the selection. Don’t also bind it to form: it would show twice.class="btn-primary" (e.g. a notice’s “Send now”, a convalidation’s next step): inside the dropdown every entry looks the same, but when it is the only one it becomes a highlighted header button, like a native form’s main button. Other entries keep the default btn-secondary.string attribute is a view term, translated through the .po files like any other label.static/src/js/backend/actions_dropdown.js + static/src/xml/backend/actions_dropdown.xml:
form_compilers registry entry (Odoo’s own extension point, the one mail uses for the chatter) compiles div[name='ems_actions'] into an EmsActionsDropdown component, with one slot per compiled button. Each slot’s isVisible is the button’s compiled t-if (its invisible=); groups= are already stripped server-side.EmsActionsDropdown extends Odoo’s StatusBarButtons, so it reuses visibleSlotNames. It renders the slot directly (a plain header button with its own classes) when exactly one slot is visible, a Dropdown (menu class o_ems_actions_menu) with one DropdownItem per visible slot (o-dropdown-item-unstyled-button, the same wrapping Odoo uses for header buttons folded into a menu) when there are more, or nothing when no slot is visible.FormRenderer.components, where the compiled form template resolves it.FormController compiles the header a second time with asDropdownItems). A patch on FormCompiler.compileHeader unwraps the div in that pass, so its buttons become ordinary cog entries instead of a dropdown nested inside the cog menu.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.
clickAction(name, content) opens the dropdown and clicks one entry, or clicks the lone header button when it is the only action.checkActions({offered, notOffered}, content) opens it, checks which entries it lists and closes it again (or checks the lone header button). offered must not be empty: it is what proves the actions have rendered.loneAction(name, content): exactly one action applies, so it is a plain header button and there is no dropdown.noActions(content): nothing applies, so no dropdown is rendered. With nothing else in the header, Odoo also leaves out the whole status bar.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.
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).
class="o_ems_header_actions" on the <list>; or 'ems_header_actions': 1 in the
action’s context, for a list view shared with a native app (the enrollments’ sale.order list is
also the Sales app’s, which must keep its own buttons loose).applicants.xml), Propostes de matrícula (list_tutor.xml), the
contact data requests list (request.xml) and Matrícules (action_ems_enrollments).<header> buttons, so they keep invisible=, groups= and
confirm=; a display="always" button (shown with no selection) stays loose.groups= and invisible=), so a role offered a single action on an
opted-in list gets a plain button.static/src/js/backend/list_header_actions.js + static/src/xml/backend/list_header_actions.xml:
a ListController patch (emsHeaderActions, emsHeaderActionButtons, emsHeaderActionsDropdown) and an extension of
web.ListView that renders EmsListActionsDropdown (one MultiRecordViewButton per entry, the
same component Odoo uses for header buttons) and stops rendering them loose. Small screens are
left alone: Odoo already moves header buttons into its cog menu there.clickListHeaderAction(name, content) in actions_dropdown_helpers.js, which handles
both the dropdown and the lone button.