Odoo Help

0

confirmation dialog box in Odoo

By
Anybox
on 12/22/15, 10:43 AM 1,646 views

Hello,

i'd like to get a value in a confirmation dialog box in odoo. I have a form with a select. When I choose a value in the select and click the save button, I have a diablog box with a message. In this message i'd like to get the selected value. An idea ?

1
Axel Mendoza
On 12/22/15, 2:57 PM

You could create an wizard to display that message with one html field that contains the message, like this example I have created in the old api:

from openerp.tools.translate import _

from openerp.osv import fields, osv

class dialog_box(osv.osv_memory):

_name = 'dialog.box'

_description = 'dialog.box'

_columns = {

'title': fields.char(string="Title", size=100, readonly=True),

'message': fields.text(string="Message", readonly=True),

}

_req_name = 'title'

def _get_view_id(self, cr, uid):

"""Get the view id

@return: view id, or False if no view found

"""

res = self.pool.get('ir.model.data').get_object_reference(cr, uid,

'web_ext', 'dialog_box_form')

return res and res[1] or False

def message(self, cr, uid, id, context):

message = self.browse(cr, uid, id)

self.__logger.info('%s: %s' % (message.title, message.message))

res = {

'name': '%s' % _(message.title),

'view_type': 'form',

'view_mode': 'form',

'view_id': self._get_view_id(cr, uid),

'res_model': 'dialog.box',

'domain': [],

'context': context,

'type': 'ir.actions.act_window',

'target': 'new',

'res_id': message.id,

'options': {'width': 400},

}

return res

def show_confirm(self, cr, uid, data, context=None):

id = self.create(cr, uid, data)

res = self.message(cr, uid, id, context)

return res

dialog_box()


<?xml version="1.0" encoding="UTF-8"?>

<openerp>

<data>

<record id="dialog_box_form" model="ir.ui.view">

<field name="name">dialog.box.form</field>

<field name="model">dialog.box</field>

<field eval="20" name="priority"/>

<field name="arch" type="xml">

<form string="Warning">

<field name="message" nolabel="1" widget="html"/>

<footer>

<button string="Ok" class="oe_link" special="cancel"/>

</footer>

</form>

</field>

</record>

</data>

</openerp>

To use it you just need to call:
return self.pool.get('dialog.box').show_confirm(cr, uid, {'message': 'hello world', 'title': 'test'})
and it will display a confirmation window with the provided message and title



thanks but are you sure your code works ? I cannot see the message into the dialog box :(

Anybox
on 12/23/15, 1:55 AM

The dialog box will show the field message, that will take the value that you pass in the show_confirm method call, you could put it there the value you need too, even html, for the example I pass 'hello world' and that is what will display the dialog box

Axel Mendoza
on 12/23/15, 1:59 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.

Register

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

1 follower(s)

Stats

Asked: 12/22/15, 10:43 AM
Seen: 1646 times
Last updated: 12/22/15, 2:57 PM