This question has been flagged
3 Replies
34116 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:

<openerp> 
<data>
<!--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">
<group>
<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)]}"/>
</group>
</xpath>
</field>
</record>
</data>
</openerp>

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:

 @api.multi 
def check_outlook_credentials(self):
self.ensure_one()
_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?

Yenthe

Avatar
Discard
Best Answer

Hello,

I think it is what you seek : http://stackoverflow.com/questions/31963214/odoo-prevent-button-from-closing-wizard

Avatar
Discard
Author

@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 \https://stackoverflow.com/a/43785166/95552. I tried this and this works.

def check_outlook_credentials(self):
return {
        "type": "set_scrollTop",
    }
Avatar
Discard
Best Answer

Anyone got the actual solution for this?

Avatar
Discard