[IMP] core: allow both action & children on root node

Reported by VFE, odoo/odoo#54564 missed one of the use cases in menus:
normally a menu can have *either* sub-menus or an action (aka only
"leaf" menu items can have actions), however there's an exception for
root (application) menus: those can have an action, which is used as
the application's action, that is, what gets executed when opening the
application itself.

* root menus were already special cased (to allow a ``web_icon``),
  expand this to allow both action and submenus
* modify the alternatives -- submenu-items and menuitems with a parent
  -- so they keep the behavior of allowing *either* an action or
  children

closes odoo/odoo#55144

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
Xavier Morel
2020-07-30 05:37:05 +00:00
parent a647497b51
commit 37a7aed189
2 changed files with 32 additions and 29 deletions
+17 -21
View File
@@ -215,26 +215,22 @@
name="Notes"
sequence="3"
action="note.action_note_note"
web_icon="note,static/description/icon.png"/>
<menuitem
id="menu_note_configuration"
name="Configuration"
sequence="100"
parent="menu_note_notes"
groups="base.group_no_one"/>
<menuitem
id="menu_notes_stage"
name="Stages"
parent="menu_note_configuration"
action="note.action_note_stage"
sequence="21"/>
<menuitem
id="notes_tag_menu"
parent="menu_note_configuration"
action="note_tag_action"
sequence="22"/>
web_icon="note,static/description/icon.png">
<menuitem
id="menu_note_configuration"
name="Configuration"
sequence="100"
groups="base.group_no_one">
<menuitem
id="menu_notes_stage"
name="Stages"
action="note.action_note_stage"
sequence="21"/>
<menuitem
id="notes_tag_menu"
action="note_tag_action"
sequence="22"/>
</menuitem>
</menuitem>
</odoo>
+15 -8
View File
@@ -234,8 +234,9 @@
</rng:optional>
<rng:optional><rng:attribute name="groups"/></rng:optional>
<rng:optional><rng:attribute name="active"/></rng:optional>
</rng:define>
<rng:define name="submenuitem_contents">
<rng:optional>
<!-- menu can't have both children and action -->
<rng:choice>
<rng:attribute name="action"/>
<rng:oneOrMore>
@@ -247,19 +248,25 @@
<rng:define name="menuitem">
<rng:element name="menuitem">
<rng:ref name="menuitem_attrs"/>
<rng:optional>
<rng:choice>
<!-- can't have submenus with icons -->
<rng:choice>
<!-- a root menu can have a web_icon, an action and children -->
<rng:group>
<rng:optional><rng:attribute name="web_icon"/></rng:optional>
<rng:optional><rng:attribute name="action"/></rng:optional>
<rng:zeroOrMore><rng:ref name="submenuitem"/></rng:zeroOrMore>
</rng:group>
<!-- a non-root menu can have a parent and either an action or submenus -->
<rng:group>
<rng:attribute name="parent"/>
<rng:attribute name="web_icon"/>
</rng:choice>
</rng:optional>
<rng:ref name="submenuitem_contents"/>
</rng:group>
</rng:choice>
</rng:element>
</rng:define>
<!-- menuitem except no parent (is implicit) or web_icon attributes -->
<rng:define name="submenuitem">
<rng:element name="menuitem">
<rng:ref name="menuitem_attrs"/>
<rng:ref name="submenuitem_contents"/>
</rng:element>
</rng:define>