New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] web, project: Add topbar actions #158441
base: master
Are you sure you want to change the base?
Conversation
7077a9a
to
8fd69b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work, thanks a lot! 🔥 🔥
addons/web/static/src/search/search_bar_menu/search_bar_menu.js
Outdated
Show resolved
Hide resolved
092762e
to
e3ed922
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting there 🔥
showTopBar: !!this.env.config.fromParentAction, | ||
topBarActions: this.env.config.topBarActions, | ||
newActionIsShared: false, | ||
newActionName: `${this.currentTopBarAction?.name} Custom`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.currentTopBarAction
can't be undefined, can it?
But looks like .name
could be, in which case we would have undefined Custom
.
I think we should do ${this.currentTopBarAction.name || <find the name of the model> || 'Action'} Custom
,
or something like that. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore my first line 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, this.currentTopBarAction
can be undefined when the component is mounted, you can try, and I agree that we should put a fallback default name I case of no currentTopBarAction. I would go for directly putting "Action" and not try to find the name of the model, which could sometimes be undeterministic and pprovide strange results.
const topBarActions = | ||
view.type === "form" ? [] : context.parentActionChildren || action.children_ids; | ||
const fromParentAction = (view.type !== "form" && context.fromParentAction) || false; | ||
const parentActionId = topBarActions?.[0]?.parent_action_id[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can topBarActions
be undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, if there is no parentActionChildren
or children_ids
in the context, which is happening when no topbar_actions
is defined
@@ -25,6 +25,7 @@ class IrFilters(models.Model): | |||
"When left empty the filter applies to all menus " | |||
"for this model.") | |||
active = fields.Boolean(default=True) | |||
topbar_action_id = fields.Many2one('ir.actions.topbar', string="The topbar action this filter is applied to", ondelete="cascade") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
if "action_id" in vals and isinstance(vals["action_id"], list): | ||
vals["action_id"] = vals["action_id"][0] | ||
if "parent_action_id" in vals and isinstance(vals["parent_action_id"], list): | ||
vals["parent_action_id"] = vals["parent_action_id"][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the call is in your code. Can't we change it?
What is usually the value of a many2one in the vals of a create?
e3ed922
to
7b7835f
Compare
const { action_id, parent_action_id } = currentTopBarAction; | ||
const values = { | ||
...currentTopBarAction, | ||
parent_action_id: parent_action_id[0], | ||
action_id: action_id[0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@auon-odoo follow-up to my previous comment that is saying where I added lines to delete the crappy logic in the python model file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well now that I delete the lines, the response to the comment does not appear :/ the "crappy logic" reference to the logic in the override of the create method in the model ir.actions.topbar_actions
const enrichedNewTopBarAction = { | ||
...values, | ||
parent_action_id, | ||
action_id, | ||
id: topBarActionId, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@auon-odoo And here also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much 🎖️
4a0b525
to
af4ffeb
Compare
a6d4689
to
007f245
Compare
9a61433
to
62a07ff
Compare
be29afb
to
21bd35f
Compare
This update introduces the implementation of topbar actions, enabling the addition of a topbar in the control panel for seamless toggling among various actions. Functionnal specifications: * This task aims to centralize and access models related to the current parent model. * We introduce the concept of topbar action. If a model has topbar actions, then a button with an 'eye' icon is displayed in the control panel. * When the user clicks the button, the topbar appears. * The top bar consists of the various topbar actions chosen as visible by the user. By default, the topbar only displays the current action (or the first available). * There is a dropdown button to the right of the topbar that displays all the actions available to the user. These actions depend on the model , but it's also possible that there is a domain on these actions making them invisible. For example, a project without the 'allow timesheets' option will not display the 'Timesheets' action. * The default actions cannot be deleted by the user; they can only decide whether to display them or not. The visibility of actions is different for each model but also for each model ID, meaning, for example, that the actions visible in one project will not be the same for another. * Each user can also save the current view and thus create a new topbar action. They can decide to share this topbar action so that it is visible to everyone, or not. The view type and filters are saved when creating a new topbar action. Those saved filters are saved as favorites filters that cannot be deleted while the topbar action exists. * If the user has the rights, they can also drag and drop the actions to reorder them. This order will be the same for everyone, and if the concerned actions are default actions, the order will also be common to all records of the concerned model. * On Mobile, only a dropdown is displayed with the current action. When the dropdown is unfolded, all available actions are displayed. It is not possible to drag and drop. Deleting is always available, as well as the creation of new actions. * The breadcrumbs should never push new items. When navigating between topbar actions, the breadcrumbs should be replaced. ------------------------------------------------------------------------ In order to create a new default topbar action for a model, the developer has to create an xml record of that structure: <record id="<id>" model="ir.actions.topbar"> <field name="res_model"><parent_res_model></field> <field name="parent_action_id" ref="<xml_id_parent_action>"/> <!-- for the triggered action, the developer can either choose between a xml action id or a python action --> <field name="action_id" ref=<triggered_action_id>/> <field name="python_action"><python_action></field> <!-- name is optionnal if the an action_id is declared --> <field name="name"><name_of_the_topbar_action></field> <!-- optionnal --> <field name="sequence"><sequence_order_integer></field> <field name="domain"><domain_to_filter_topbar_actions></field> <field name="context"><additional_context_keys></field> <field name="default_view_mode"><default_view></field> </record> taskid:3750721
21bd35f
to
c96be45
Compare
def _get_readable_fields(self): | ||
return super()._get_readable_fields() | { | ||
"context", "mobile_view_mode", "domain", "filter", "groups_id", "limit", | ||
"res_id", "res_model", "search_view_id", "target", "view_id", "view_mode", "views", | ||
"res_id", "res_model", "search_view_id", "target", "view_id", "view_mode", "views", "children_ids", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a one2many to have a real field. 🙂
This update introduces the implementation of topbar actions, enabling
the addition of a topbar in the control panel for seamless toggling
among various actions.
Functionnal specifications:
This task aims to centralize and access models related to the current
parent model.
We introduce the concept of topbar action. If a model has topbar
actions, then a button with an 'eye' icon is displayed in the control
panel.
When the user clicks the button, the topbar appears.
The top bar consists of the various topbar actions chosen as visible
by the user. By default, the topbar only displays the current action
(or the first available).
There is a dropdown button to the right of the topbar that displays
all the actions available to the user. These actions depend on the model
, but it's also possible that there is a domain on these actions making
them invisible. For example, a project without the 'allow timesheets'
option will not display the 'Timesheets' action.
The default actions cannot be deleted by the user; they can only
decide whether to display them or not. The visibility of actions is
different for each model but also for each model ID, meaning, for
example, that the actions visible in one project will not be the same
for another.
Each user can also save the current view and thus create a new topbar
action. They can decide to share this topbar action so that it is
visible to everyone, or not. The view type and filters are saved when
creating a new topbar action. Those saved filters are saved as favorites
filters that cannot be deleted while the topbar action exists.
If the user has the rights, they can also drag and drop the actions to
reorder them. This order will be the same for everyone, and if the
concerned actions are default actions, the order will also be common to
all records of the concerned model.
On Mobile, only a dropdown is displayed with the current action. When
the dropdown is unfolded, all available actions are displayed. It is
not possible to drag and drop. Deleting is always available, as well as
the creation of new actions.
The breadcrumbs should never push new items. When navigating between
topbar actions, the breadcrumbs should be replaced.
In order to create a new default topbar action for a model, the
developer has to create an xml record of that structure:
taskid:3750721
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr