Search Here

Display Confirmation Message Dialog Box in Odoo

In this article I will show you how to add or display confirmation display box / message box on button click. Before going into deep we need to know problem statement. In some scenario we need to ask from user is he/she want to do further processing or not on button click.
Display Confirmation Message Dialog Box on Button Click in Odoo

Display Confirmation Message Dialog Box in Odoo

For example we have some document which needs to be approved by higher authorities of a company. And before submitting it to we want to ask confirmation from user. So guys to achieve this goal follow these steps.

Read More: How to Send Email on Button Click in Odoo


show_message_box_odoo.py



Code Description

In above code we created a class named "display_dialog_box", and in that class we create one field named "text" this field holds our text message that we want to display our user before taking some action on button click.

Now we are going to create our dialog box / message box interface. In Odoo/ERP its not a big deal if you don't have any idea about form view than read.

Read More: How to Create Form and Tree View in Odoo

show_message_box_odoo.xml



Code Description

In above code we have created form view to display confirmation message box. This form view contains one field that will display our confirmation message and a footer that contains tow buttons, the first one is for "Yes", "Ok" and the second one is for cancellation of the form.

Now that we have class and form view associated to that class. Now in above code after view we have created action menu for that model or class, because when we click on button than this action menu will popup or open dialog box or message confirmation box. 

Read More: How to Create Window Action and Menu Item in Odoo


Now its time to open dialog box on button click.

open_dialog_box_on_button_click.py


Code Description

Above code will first delete previous message from database and create new message using Odoo create method. And return or display confirmation message or dialog box in a new window.

Post a Comment

0 Comments