DTCloud 里面的提示 notification

92 阅读1分钟

一、通用提示

from dtcloud.tools.translate import _
 
# 方法一
notification = {
    'type': 'ir.actions.client',
    'tag': 'display_notification',
    'params': {
        'title': ('请求成功'),
        'message': '下线用户成功',
        'sticky': False,
        'type': 'success'
    },
}
return notification
 
# 方法二
return {
    'type': 'ir.actions.client',
    'tag': 'display_notification',
    'params': {
        'title': '未成功下线',
        'message': '未成功下线,可能该会话已过期',
        'sticky': False,
        'className': 'bg-warning'
    }
}
 
# 方法三
return {
    'type': 'ir.actions.client',
    'tag': 'display_notification',
    'params': {
        'title': _('下线失败'),
        'message': _('发生未知错误,可能未响应或其他'),
        'sticky': True,
        'className': 'bg-danger'
    }
}

b1d1147119ce8e09f71af16df2c7fba4.png

二、向导提示后关闭当前页

notification = {
    'type': 'ir.actions.client',
    'tag': 'display_notification',
    'params': {
        'title': u'图片导入',
        'message': message,
        'sticky': False,
        'type': 'success',
        'next': {
            'type': 'ir.actions.act_window_close'
        },
    },
}
return notification

三、注意事项

后端 return 提示无反应
注意:在后端使用提示框时,如果点击按钮触发的是第一个函数,而你是在第二个函数里面 return 提示框,那么不会显示任何效果!如下所示,该代码将无响应。

e50fb9e45a4454491c9f4c32b023e5cc.png
作者:中亿丰数字——何双新