This question has been flagged
6 Replies
14472 Views

I have a requirement, to launch a wizard in my python. could anyone help me please!

here is my view:

        <record id="my_config_view_form" model="ir.ui.view">
            <field name="name">my.item.config.view</field>
            <field name="model">my.model.config</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="base.res_config_view_base"/>
                <field name="arch" type="xml">

                    <group string="res_config_contents" position="replace">
                        <label colspan="4" align="0.0" string="
                            Configure this item by defining its field"/>
                        <field name="my_field"/>
                    </group>
                    <xpath expr="//button[@name='action_skip']"  position="attributes">
                        <attribute name="string">Proceed</attribute>
                        <attribute name="class">oe_highlight</attribute>
                    </xpath>
                    <xpath expr="//button[@name='action_next']" position="attributes">
                        <attribute name="string">Ok</attribute>
                        <attribute name="class">none</attribute>
                    </xpath>
                </field>
        </record>

        <record id="my_config_window" model="ir.actions.act_window">
            <field name="name">My config window</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">my.model.config</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="my_config_view_form"/>
            <field name="view_mode">form</field>
            <field name="target">new</field>
        </record>

        <record id="my_config_step" model="ir.actions.todo">
            <field name="action_id" ref="my_config_window"/>
        </record>

I wrote this code but the wizard is not not showing:

def onchange_test_wizard(self, cr, uid, ids, context=None):


        return {
            'name': 'test',
            'view_type': 'form',
            'view_mode': 'form',
            'view_id': 'my_config_view_form',
            'res_model': 'my.model.config',
            'domain': [],
            'context': context,
            'type': 'ir.actions.act_window',
            'target': 'new',
        }
Avatar
Discard
Author

could anyone write a python code to launch this wizard? Please!

Hi, you cannot return an action or view or wizard in an onchange function. You can find example of return view in python in account/account.py with function "execute" or "fiedls_view_get", but are used to override an existant function. Bye

Author

Hello, thank you for your answer. but what if I really want to return in in onchange function. how can i do?

Hi, I repeat a second time, it is not possible to return a view in an onchange. Bye

Best Answer

Hi, 

First of all, you can not put your own model when inheriting view. So you have to put res.config in the model field and you can call wizard in button action.

Thanks

Avatar
Discard