Odoo Wizard Tutorials

Create Action menu item and process data with a wizard

An Action menu appears on top of a model list or single page. We can add a new action to handle data according to our demand.

<odoo>
    <data>
        
        <act_window id="custom_action"
                    name="Custom Action"
                    src_model="sale.order"
                    res_model="wizard.sale.order.custom"
                    view_mode="form"
                    target="new"
                    multi="True"/>
        <record model="ir.ui.view" id="custom_form_view">
            <field name="name">wizard.sale.order.custom.form</field>
            <field name="model">wizard.sale.order.custom.cancel</field>
            <field name="arch" type="xml">
                <form string="Quotation">
                    <group>
                        <field name="order_ids"/>
                    </group>
                    <footer>
                        <button name="confirm_action" type="object" string="Confirm Action" class="oe_highlight"/>
                        or
                        <button special="cancel" string="Cancel"/>
                    </footer>
                </form>
            </field>
        </record>

    </data>
</odoo>
class CustomAction(models.TransientModel):
    _name = 'wizard.sale.order.custom'

    def _default_orders(self):
        return self.env['sale.order'].browse(self._context.get('active_ids'))

    sale_ids = fields.Many2many('sale.order', string='Sales', default=_default_orders,
                                 auto_join=True, required=True, readonly=True)

    @api.multi
    def confirm_action(self):
        if self.sale_ids:
        	for sale in self.sale_ids:
        		# Do something here

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close