odoo开发笔记 -- 错误、警告、提示、确认信息显示
2018-01-02 15:26
543 查看
1.检查业务逻辑中的错误,终止代码执行,显示错误或警告信息:
raise osv.except_osv(_('Error!'), _('Error Message.'))
示例代码:
2.字段的 onchange 事件中返回值,同时返回提示信息:
warning = {
'title': _('Warning!'),
'message' : _('[b]Warning Message.')[/b]
}
return {'warning': warning, 'value': value}
示例代码:
3.视图中 button 按钮点击时显示确认信息:【直接加上"confirm"属性,就可以实现,点击按钮的时候,弹出窗口,提示“是否确认操作”的提示框】
<button name="cancel_voucher" string="Cancel Voucher" type="object" states="posted" confirm="Are you sure you want to unreconcile this record?"/>
相关参考:
http://www.cnblogs.com/cnshen/p/3205405.html
raise osv.except_osv(_('Error!'), _('Error Message.'))
示例代码:
#删除当前销售单,需要验证销售单的状态 def unlink(self, cr, uid, ids, context=None): for rec in self.browse(cr, uid, ids, context=context): if rec.state not in ['draft']: raise osv.except_osv(_(u'警告!'),_(u'您不能删除以下状态的销售单 %s .')%(rec.state)) if rec.create_uid.id != uid: raise osv.except_osv(_(u'警告!'),_(u'您不能删除他人创建的单据.')) return super(sale, self).unlink(cr, uid, ids, context)
2.字段的 onchange 事件中返回值,同时返回提示信息:
warning = {
'title': _('Warning!'),
'message' : _('[b]Warning Message.')[/b]
}
return {'warning': warning, 'value': value}
示例代码:
def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context=None): context = context or {} if not pricelist_id: return {} value = { 'currency_id': self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context).currency_id.id } if not order_lines: return {'value': value} warning = { 'title': _('Pricelist Warning!'), 'message' : _('If you change the pricelist of this order (and eventually the currency), prices of existing order lines will not be updated.') } return {'warning': warning, 'value': value}
3.视图中 button 按钮点击时显示确认信息:【直接加上"confirm"属性,就可以实现,点击按钮的时候,弹出窗口,提示“是否确认操作”的提示框】
<button name="cancel_voucher" string="Cancel Voucher" type="object" states="posted" confirm="Are you sure you want to unreconcile this record?"/>
相关参考:
http://www.cnblogs.com/cnshen/p/3205405.html
相关文章推荐
- openerp学习笔记 错误、警告、提示、确认信息显示
- openerp学习笔记 错误、警告、提示、确认信息显示
- lnmp 开发环境下显示php错误信息
- 启用win7下IIS7的http500错误详细信息提示显示的方法步骤
- Makefile 高亮显示Error、Warning等错误以及警告信息
- 开发Android调试时logcat不显示输出错误信息的解决办法
- iOS开发笔记之从AFNetworking返回的Error中取出服务端返回的错误信息
- [Teamcenter 2007 开发实战] 获取错误或提示信息
- 关闭MOSS的友好提示 ,显示详细的错误信息ZZ
- PHP开发中,打开错误信息提示
- 开发闲聊(二)--eclipse工程目录中不显示红叉(代码错误提示)
- selenium实践-如何验证警告、确认、提示信息
- 如何验证警告/确认/提示信息
- android开发-使用Toast显示提示信息框
- Android 4.0+ EditText.setError("错误提示信息")不显示文字的解决方法
- yii中设置提示成功信息,错误提示信息,警告信息
- js在页面显示错误提示信息的写法
- Spring Security学习笔记错误信息提示(三)
- C# WinForm开发系列之chart控件画折线图和柱形图并自定义鼠标移动到数据标记点显示提示信息
- .Android开发在Eclipse环境中无法显示提示信息This element neither has attached