Skip to Content
Menu
This question has been flagged
2 Replies
9253 Views

Hello,

I am trying to create a simple wizard to help me create popups after i call some methods or wizards. Currently my solution works for odoo12.0, but for some reason does not for odoo10.0. This is my python code:

from odoo import fields, models


class DialogBox(models.TransientModel):
_name = 'hr.rfid.wiz.dialog.box'

title = fields.Char(string='Title', readonly=True)
text = fields.Char(string='Text', readonly=True)


def return_wiz_form_view(res_model, res_id):
return {
'type': 'ir.actions.act_window',
'res_model': res_model,
'view_mode': 'form',
'view_type': 'form',
'res_id': res_id,
'views': [(False, 'form')],
'target': 'new',
}


def create_dialog_box(env, title, text):
return env['hr.rfid.wiz.dialog.box'].create([{
'title': title,
'text': text,
}])


def return_dialog_box(d_box):
return return_wiz_form_view('hr.rfid.wiz.dialog.box', d_box.id)


def create_and_ret_d_box(env, title, text):
d_box = create_dialog_box(env, title, text)
return return_dialog_box(d_box)

My xml code looks like this:

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

<odoo>
<data>
<record id="hr_rfid_dialog_box_form" model="ir.ui.view">
<field name="name">hr.rfid.dialog.box.form</field>
<field name="model">hr.rfid.wiz.dialog.box</field>
<field name="arch" type="xml">
<form string="">
<div>
<h2><field name="title" /></h2>
<p><field name="text" /></p>
</div>

<footer>
<button special="cancel" string="Ok" class="oe_highlight" />
</footer>
</form>
</field>
</record>
</data>
</odoo>

This is how i return from my other wizard:

return create_and_ret_d_box(self.env, 'Title123', 'Text123')

but all odoo10.0 shows is this: https://i.imgur.com/r9d8a84.png

Any idea why this happens?

Avatar
Discard

it's showing exactly what you defined in view

Author

No, it does not? What are you talking about? It shows the fields "Title" and "Text" in odoo12 with correct formatting and everything.

Display confirmation box/dialog box: https://goo.gl/qhWNZJ

Author

I'm sorry but i don't see the difference in my code and the code in the article you posted. They are completely analogous.

Author Best Answer

Found out the issue, i wrote this function wrong:

def create_dialog_box(env, title, text):
    return env['hr.rfid.wiz.dialog.box'].create([{
         'title': title,
         'text': text,
     }])

Should be:

def create_dialog_box(env, title, text):
    return env['hr.rfid.wiz.dialog.box'].create({
         'title': title,
         'text': text,
     })
Avatar
Discard