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

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')
def check_outlook_credentials(self):
_logger.critical('Do a check here ' + str(
return None

The code to re-open the wizard:

def check_outlook_credentials(self):
_logger.critical('Do a check here ' + str(
view_id = self.pool[''].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',
'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?


3 Answers
Guillaume Seran
Best Answer
1 Comment

@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..

Best Answer

From \ I tried this and this works.

def check_outlook_credentials(self):
return {
        "type": "set_scrollTop",