菜单

这有一个菜单项的模板:

  1. <menuitem id="menuitem_id"
  2. name="Position/Of/The/Menu/Item/In/The/Tree"
  3. action="action_id"
  4. icon="NAME_FROM_LIST"
  5. groups="groupname"
  6. sequence="<integer>"/>

其中

  • id用来在菜单项表中区别不同的菜单,这个标识符是唯一的,必须的字段。

  • name定义了该菜单在menu层次中的位置。元素间通过斜杠“/”来划分。菜单名称中没有斜杠的是顶级菜单项。这个字段是必须的。

  • action指定了动作的标识符,这个动作必须在action表(ir.actions.act_window)中定义过了。我们注意到这个字段不是必须的:你可以定义没有相应动作的菜单项。当我们为菜单项定义自制的按钮,就像文件夹的功能时,这个没有动作的菜单是有用的。

  • icon指定了菜单项将会使用哪个按钮。默认的是STOCK_OPEN.

    • 可用的按钮有: STOCK_ABOUT, STOCK_ADD, STOCK_APPLY, STOCK_BOLD, STOCK_CANCEL, STOCK_CDROM, STOCK_CLEAR, STOCK_CLOSE, STOCK_COLOR_PICKER, STOCK_CONNECT, STOCK_CONVERT, STOCK_COPY, STOCK_CUT, STOCK_DELETE, STOCK_DIALOG_AUTHENTICATION, STOCK_DIALOG_ERROR, STOCK_DIALOG_INFO, STOCK_DIALOG_QUESTION, STOCK_DIALOG_WARNING, STOCK_DIRECTORY, STOCK_DISCONNECT, STOCK_DND, STOCK_DND_MULTIPLE, STOCK_EDIT, STOCK_EXECUTE, STOCK_FILE, STOCK_FIND, STOCK_FIND_AND_REPLACE, STOCK_FLOPPY, STOCK_GOTO_BOTTOM, STOCK_GOTO_FIRST, STOCK_GOTO_LAST, STOCK_GOTO_TOP, STOCK_GO_BACK, STOCK_GO_DOWN, STOCK_GO_FORWARD, STOCK_GO_UP, STOCK_HARDDISK, STOCK_HELP, STOCK_HOME, STOCK_INDENT, STOCK_INDEX, STOCK_ITALIC, STOCK_JUMP_TO, STOCK_JUSTIFY_CENTER, STOCK_JUSTIFY_FILL, STOCK_JUSTIFY_LEFT, STOCK_JUSTIFY_RIGHT, STOCK_MEDIA_FORWARD, STOCK_MEDIA_NEXT, STOCK_MEDIA_PAUSE, STOCK_MEDIA_PLAY, STOCK_MEDIA_PREVIOUS, STOCK_MEDIA_RECORD, STOCK_MEDIA_REWIND, STOCK_MEDIA_STOP, STOCK_MISSING_IMAGE, STOCK_NETWORK, STOCK_NEW, STOCK_NO, STOCK_OK, STOCK_OPEN, STOCK_PASTE, STOCK_PREFERENCES, STOCK_PRINT, STOCK_PRINT_PREVIEW, STOCK_PROPERTIES, STOCK_QUIT,STOCK_REDO, STOCK_REFRESH, STOCK_REMOVE, STOCK_REVERT_TO_SAVED, STOCK_SAVE, STOCK_SAVE_AS, STOCK_SELECT_COLOR, STOCK_SELECT_FONT, STOCK_SORT_ASCENDING, STOCK_SORT_DESCENDING, STOCK_SPELL_CHECK, STOCK_STOP, STOCK_STRIKETHROUGH, STOCK_UNDELETE, STOCK_UNDERLINE, STOCK_UNDO, STOCK_UNINDENT, STOCK_YES, STOCK_ZOOM_100, STOCK_ZOOM_FIT, STOCK_ZOOM_IN, STOCK_ZOOM_OUT, terp-account, terp-crm, terp-mrp, terp-product, terp-purchase, terp-sale, terp-tools, terp-administration, terp-hr, terp-partner, terp-project, terp-report, terp-stock
  • groups 指定哪个组的用户可以看到这个菜单(例如:groups=”admin”)。想要得到更多信息可以看“Management of Access Rights”。多个组的话可以用逗号分开(如:groups=”admin,user”)。

  • sequence 是个整数类型,用于为菜单项中的菜单排序。更高的sequence number在菜单项的更下面。这个字段不是必须的:如果sequence没有指定值,菜单项将会得到一个默认的数值10。有相同数值的菜单项按照创建顺序来排序(_order = “sequence,id“)。

例子

在server/bin/addons/sale/sale_view.xml中,我们有:

  1. <menuitem name="Sales Management/Sales Order/Sales Order in Progress" id="menu_action_order_tree4" action="action_order_tree4"/>

想要更改菜单项的图标:

  1. * Highlight the menu which icon you want to change
  2. * Select the "Switch to list/form" option from the "Form" menu. This will take you to the Munu editor.
  3. * From here you can change icon of your selected menu.