تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
12176 أدوات العرض

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 ?

الصورة الرمزية
إهمال

Display confirmation display box / message box on button click: http://learnopenerp.blogspot.com/2017/12/how-to-display-confirmation-display-box.html

أفضل إجابة

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

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

أفضل إجابة

May be this will helpful

 
 

الصورة الرمزية
إهمال

this will not fit for what asked in question