Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
39511 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello,

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

From \https://stackoverflow.com/a/43785166/95552. I tried this and this works.

def check_outlook_credentials(self):
return {
        "type": "set_scrollTop",
    }
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Anyone got the actual solution for this?

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
Button Functions Đã xử lý
2
thg 1 22
4908
1
thg 8 23
1892
1
thg 2 18
3361
0
thg 6 16
2728
1
thg 7 23
2289