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.

        <act_window id="custom_action"
                    name="Custom Action"
        <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">
                        <field name="order_ids"/>
                        <button name="confirm_action" type="object" string="Confirm Action" class="oe_highlight"/>
                        <button special="cancel" string="Cancel"/>

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)

    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.

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.