How to open success message popup in odoo

Odoo doesn’t support popup message out of the box. There is this raise Warning(message) which opens a popup to show errors. However, you SHOULD never use them to show message to users.

In Odoo, everything runs inside a big transaction. When there is a raised exception, Odoo will carry out rollback in the database for all committed transactions. So it is not recommended to use this approach to show informational or success message.

Our correct approach is to use a wizard.

Wizard class

class MyModuleMessageWizard(models.TransientModel):
    _name = 'mymodule.message.wizard'
    _description = "Show Message"

    message = fields.Text('Message', required=True)

    def action_close(self):
        return {'type': 'ir.actions.act_window_close'}


<!--Message Wizard -->
<record id="mymodule_message_wizard_form" model="ir.ui.view">
    <field name="name">mymodule.message.wizard.form</field>
    <field name="model">mymodule.message.wizard</field>
    <field name="arch" type="xml">
            <field name="message" readonly="True"/>
                <button name="action_close" string="Ok" type="object" default_focus="1" class="oe_highlight"/>

Then call the wizard from any actions.

def mymodule_open_popup(self):
    mymodule = self.get_server_info(
    message_id = self.env['mymodule.message.wizard'].create({'message': 'Your action was completed.'})
    return {
        'name': 'Message',
        'type': 'ir.actions.act_window',
        'view_mode': 'form',
        'res_model': 'mymodule.message.wizard',
        'target': 'new'

Leave a Comment

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