Odoo Help


Confirm message dialog from Python code

on 12/22/14, 2:32 PM 4,042 views

Hello, I am developing a new module in Odoo 8.

I need to display a confirm message (I see that I can do this adding the confirm="confirm message" in button XML) from the Python code, in a method.

For example: I override the create method of sale.order model.  I want to check if the total of the sale is under X value. If the value > X, I display a confirm message like "Do you really confirm this sale?" and catch the button pressed for the user to decide what action I do.


So what is your question?

Stephen Mack
on 12/22/14, 3:06 PM

My question is, how can I display the message from Python code and how can I catch the button pressed by the user?

on 12/22/14, 3:48 PM



| 5 3 6
Jakarta, Indonesia
On 12/23/14, 1:58 AM

AFAIK, this is a feature lacking in Odoo.  If you want to stop the processing forward (not a confirmation but a validation that stops the processing from moving forward) you can raise an exception.  But I am not aware of anyway to display a confirmation message that user can choose to go forward or not.  You can display a warning message using on_change (e.g. when the sale order line is changed, trap it using on_change, then calculate the total sales value and if it is more than X, then display a warning message).




| 5 4 6
Zagreb | Karlovac, Croatia

there is only 10 kind of people the ones that understand binary ... and others

On 12/23/14, 2:41 AM

Yes you can do that.. using a wizzard
This approach needs the method to be split in parts (before,during and after wizard)
Steps you need to do

1. create you custom method, make some computation/data colection
;then create a record in transient model and return wizard wiev for created record
2. in wizard display whatever user needs to make a choice
3. accoring to choice continue or cancel futrher actions...

hope it helps.... 


On 3/27/18, 11:19 PM

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.

For example we have some document which needs to be approved by vice chancellor of a university. And before submitting it to the vice chancellor we want to ask confirmation from user.


# Confirmation msg box for ORIC
from openerp.osv import fields,osv
from openerp.tools.translate import _
class thesis_approval_message_oric(osv.osv_memory):
    _name = "thesis.approval.message.oric"
        'text': fields.text(),


     <!--Wizard For Raise Apprval Messages Thesis ORIC-->
    <record id="wizard_message_form_for_oric" model="ir.ui.view">
            <field name="name">Thesis Wizard Message Approval Message ORIC</field>
            <field name="model">thesis.approval.message.oric</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Message" version="7.0">
                    <separator string="Message" colspan="6"/>
                    <field name="text" colspan="4" nolabel="1" readonly="1"  widget="html"/>                                                            
                    <separator colspan="6"/>
                        <button name="btn_approve_oric" type="object" string="Yes" class="oe_highlight"/>                             
                        <button special="cancel" string="No"/>                    

Button click function

    def btn_approve(self):
 text = """The case """+str(self.case_no)+""" will be forward to VC for further Approval. Are you want to proceed."""
 query='delete from thesis_approval_message_oric'
  # 'context':{'thesis_obj':self.id,'flag':'course Work completed'},

For code understanding and description please visit: http://learnopenerp.blogspot.com/2017/12/how-to-display-confirmation-display-box.html

on 3/27/18, 11:21 PM
On 12/29/14, 8:38 AM

Bole: I have created the method, and the wizard (py and xml files). How can I display the wizard message and catch the result from Python code?

Ivan: the warning message not helps me because this stops the execution of the method.

You cannot return an action/wizard from `create` method. So this won't work.

Sudhir Arya (ERP Harbor Consulting Services)
on 9/29/17, 4:12 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

4 follower(s)


Asked: 12/22/14, 2:32 PM
Seen: 4042 times
Last updated: 3/28/18, 1:10 AM