请教,按钮事件返回warning问题???????
-
请教,form中增加了一个button,返回一个warning消息,没有反映,翻阅前台js代码,发现并没有相关判断代码,本来打算include解决加入代码,总感觉这种方法不好,发现可以执行action,于是修改代码返回ir.actions.client,功能实现了,窗口提示完毕后,原来点据已经跳转了,原页面一片空白。请教更好解决方法。
[quote]@api.multi
def generate_tender(self):
if self.tender_ids.ids.len() or self.sporadic_ids.ids.len():
warning = {
'title': "Warning!",
'message': "the available num Can't be more than the num",
}
return {"type": "ir.actions.client",
"tag": "bs.warning",
"context": {'warning': warning}}[/quote] -
系统中的一个例子,也不太懂。
def change_password(self, cr, uid, old_passwd, new_passwd, context=None):
"""Change current user password. Old password must be provided explicitly
to prevent hijacking an existing user session, or for cases where the cleartext
password is not used to authenticate requests.
:return: True
:raise: openerp.exceptions.AccessDenied when old password is wrong
:raise: except_osv when new password is not set or empty
"""
self.check(cr.dbname, uid, old_passwd)
if new_passwd:
return self.write(cr, uid, uid, {'password': new_passwd})
raise osv.except_osv(_('Warning!'), _("Setting empty passwords is not allowed for security reasons!"))
def preference_change_password(self, cr, uid, ids, context=None):
return {
'type': 'ir.actions.client',
'tag': 'change_password',
'target': 'new',
}