Odoo Help


How to prevent wizard from being closed when clicking a button?

on 11/25/15, 11:40 AM 5,069 views

Hi guys,

I've inherited the default user preferences screen and added my own fields. On this form (which is a dialog) I've added a button with an action behind it. When the user clicks on this button "Test Connection" it should perform a check and it should show a notification dialog on top of the existing dialog, without closing any dialogs. The inherited view:

<!--Inherit res.partner view-->
<record id="view_res_users_inherit_outlook" model="ir.ui.view">
<field name="name">res.users.inherit.outlook</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
<field name="sequence" eval="500"/>
<field name="arch" type="xml">
<xpath expr="//group[2]" position="after">
<field name="should_sync"/>
<field name="email" attrs="{'invisible': [('should_sync','=',False)],'required':[('should_sync','=',True)]}"/>
<field name="password" attrs="{'invisible': [('should_sync','=',False)],'required':[('should_sync','=',True)]}"/>
<button name="credentials" string="Test connection" type="object" attrs="{'invisible': [('should_sync','!=',True)]}"/>

The python function:

class user_settings_outlook(models.Model): 
_inherit = 'res.users'
should_sync = fields.Boolean('Sync with Outlook')
email = fields.Char('Outlook e-mail')
password = fields.Char('Outlook password') @api.one
def check_outlook_credentials(self):
_logger.critical('Do a check here ' + str(self.email))
return None

The code to re-open the wizard:

def check_outlook_credentials(self):
_logger.critical('Do a check here ' + str(self.email))
view_id = self.pool['ir.model.data'].xmlid_to_res_id(
self._cr, self._uid, 'my_module.view_res_users_inherit_outlook
return {
'context': self.env.context,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'res.users',
'res_id': self.id,
'view_id': view_id,
'type': 'ir.actions.act_window',
'target': 'new', }

When I click on the button "Test connection" the whole dialog is closed, while it shouldn't. The wizard is automatically re-opened but it is first closed and then opened again though. Is there any way to prevent any closing and re-opening and just showing a warning?


Guillaume Seran
On 11/25/15, 11:47 AM

@Guillaume I'm sorry I think I didn't explain it far enough. I've extended my answer! The thing is that you can easily let the wizard re-open after it is closed on the button click BUT the window still closes and re-opens. Which is in my point of view no ideal behaviour..

on 11/26/15, 2:27 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.


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)


Asked: 11/25/15, 11:40 AM
Seen: 5069 times
Last updated: 6/21/17, 6:33 AM