Odoo Help

Welcome!

This community 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.

0

confirmation dialog box in Odoo

By
smorele
on 12/22/15, 10:43 AM 841 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 ?

0

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

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 :(

smorele
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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