Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launching a wizard from a button in OpenERP

I'm trying to launch a wizard from an action called from a button in OpenERP. I can launch the wizard using a side menu button just fine, but whenever I use the action in a button, I just get a couple of refreshes, without the new form opening up.

The wizard is pretty basic. Here is the code:

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="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>

And I have the code for the button with:

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

I've tried putting the straight XML id in there (without the $()d ), and I've tried using either action defined above, all with the same results. I get an error if I put a bad action name, but that's about it. Any ideas of where to go from here?

like image 215
Dan Lawson Avatar asked Oct 08 '22 03:10

Dan Lawson


1 Answers

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.

like image 190
Mohammad Alhashash Avatar answered Oct 13 '22 11:10

Mohammad Alhashash