5

我正在尝试从 OpenERP 中的按钮调用的操作启动向导。我可以很好地使用侧面菜单按钮启动向导,但是每当我在按钮中使用该操作时,我只会刷新几次,而不会打开新表单。

该向导非常基本。这是代码:

向导.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>


        <record id="view_res_partner_add_terminal_wizard" model="ir.ui.view">
            <field name="name">res.partner.terminal.form</field>
            <field name="model">res.partner.terminal</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Add terminal">
                    <group colspan="4" >
                        <separator string="Select terminals to assign" colspan="4"/>
                        <field name="terminal_id" string="Terminals" domain="[('state','=','available')]"/>
                        <newline/>
                    </group>
                    <separator string="" colspan="4" />
                    <group colspan="4" col="6">
                        <button  icon="gtk-cancel" special="cancel" string="Cancel"/>
                        <button  icon="gtk-ok" name="add_terminal" string="Assign Terminal" type="object"/>
                    </group>
               </form>
            </field>
        </record>

        <record id="action_res_partner_terminal" model="ir.actions.act_window">
            <field name="name">Assign Terminal</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner.terminal</field>
            <field name="src_model">res.partner</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_res_partner_add_terminal_wizard"/>
            <field name="target">new</field> -->
            <field name="key2">client_action_multi</field>
        </record>

        <act_window id="action_res_partner_terminal_wizard"
                name="Assign Terminal"
                res_model="res.partner.terminal" 
                src_model="res.partner"
                view_mode="form" 
                key2="client_action_multi"
                target="new"
        />


    </data>
</openerp>

我有按钮的代码:

<button  name="$(universal_account.action_res_partner_terminal_wizard)d" string="Assign Terminal" type="action" />

我已经尝试将直接的 XML id 放在那里(没有 $()d ),并且我尝试使用上面定义的任一操作,都具有相同的结果。如果我输入了错误的操作名称,我会收到一个错误,但仅此而已。关于从这里去哪里的任何想法?

4

2 回答 2

6

In your button definition replace $(...)d with %(...)d.

XML_ID substitution uses the percentage sign, not the dollar sign.

BTW, you do not need the first act_window. Defining the act_window through record tag will not create the sidebar link; you have to use the shortcut tag <act_window> or add the side bar link with ir_value record. The second act_window (action_res_partner_terminal_wizard) will create the sidebar link and get used for the button action.

于 2012-07-26T15:10:20.580 回答
-2

您的 wizard.xml 应如下所示:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_res_partner_add_terminal_wizard" model="ir.ui.view">
            <field name="name">res.partner.terminal.form</field>
            <field name="model">res.partner.terminal</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Add terminal">
                    <group colspan="4" >
                        <separator string="Select terminals to assign" colspan="4"/>
                        <field name="terminal_id" string="Terminals" domain="[('state','=','available')]"/>
                        <newline/>
                    </group>
                    <separator string="" colspan="4" />
                    <group colspan="4" col="6">
                        <button  icon="gtk-cancel" special="cancel" string="Cancel"/>
                        <button  icon="gtk-ok" name="add_terminal" string="Assign Terminal" type="object"/>
                    </group>
               </form>
            </field>
        </record>


        <record id="action_res_partner_terminal" model="ir.actions.act_window">
            <field name="name">Assign Terminal</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner.terminal</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="view_res_partner_add_terminal_wizard"/>
            <field name="target">new</field>
        </record>
    </data>
</openerp>

和 On View 按钮应该定义如下

<button  name="$(universal_account.action_res_partner_terminal)d" 
         string="Assign Terminal" 
         type="action" 
         help="Assign Terminal"/>

您必须定义ir.actions.act_windowon button 操作的 XML Id 而不是act_windowxml id。

问候。

于 2012-07-26T04:28:52.580 回答