This is the documentation for older versions of Odoo (formerly OpenERP).

See the new Odoo user documentation.

See the new Odoo technical documentation.

Action creation

Linking events to action

可用类型的事件是:

  • client_print_multi (print from a list or form)

  • client_action_multi (action from a list or form)

  • tree_but_open (double click on the item of a tree, like the menu)

  • tree_but_action (action on the items of a tree)

从事件到动作的映射是:

<record model="ir.values" id="ir_open_journal_period">
    <field name="key2">tree_but_open</field>
    <field name="model">account.journal.period</field>
    <field name="name">Open Journal</field>
    <field name="value" eval="'ir.actions.wizard,%d'%action_move_journal_line_form_select"/>
    <field name="object" eval="True"/>
</record>

如果你双击journal/period (object: account.journal.period),将会打开一个选中的向导(id=”action_move_journal_line_form_select”).

只是当用户点击特定的对象时,你可以使用res_id字段来允许这个动作。

<record model="ir.values" id="ir_open_journal_period">
    <field name="key2">tree_but_open</field>
    <field name="model">account.journal.period</field>
    <field name="name">Open Journal</field>
    <field name="value" eval="'ir.actions.wizard,%d'%action_move_journal_line_form_select"/>
    <field name="res_id" eval="3"/>
    <field name="object" eval="True"/>
</record>

当用户点击account.journal.period n°3时,这个动作将会触发。

当你声明向导,报表或是菜单时,ir.values的创建会自动由下面的标签完成:

  • <wizard... />

  • <menuitem... />

  • <report... />

所以一般不需要自己加映射。