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.
Models.py
# 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"
_columns={
'text': fields.text(),
}
thesis_approval_message_oric()
Xml
<!--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"/>
<newline/>
<separator colspan="6"/>
<footer>
<button name="btn_approve_oric" type="object" string="Yes" class="oe_highlight"/>
<button special="cancel" string="No"/>
</footer>
</form>
</field>
</record>
Button click function
@api.multi
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'
self.env.cr.execute(query)
value=self.env['thesis.approval.message.oric'].sudo().create({'text':text})
return{
'type':'ir.actions.act_window',
'name':'Message',
'res_model':'thesis.approval.message.oric',
'view_type':'form',
'view_mode':'form',
'target':'new',
# 'context':{'thesis_obj':self.id,'flag':'course Work completed'},
'res_id':value.id
}
For code understanding and description please visit: http://learnopenerp.blogspot.com/2017/12/how-to-display-confirmation-display-box.html
So what is your question?
My question is, how can I display the message from Python code and how can I catch the button pressed by the user?
hope this will helps: https://learnopenerp.blogspot.com/2017/12/how-to-display-confirmation-display-box.html