Odoo Help

Welcome!

This community 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.

0

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

By
Yenthe
on 11/25/15, 11:40 AM 1,667 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

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

Yenthe
on 11/26/15, 2:27 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/25/15, 11:40 AM
Seen: 1667 times
Last updated: 11/26/15, 2:32 AM