1.检查业务逻辑中的错误,终止代码执行,显示错误或警告信息:

 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' : _('Warning Message.')
  }
 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 按钮点击时显示确认信息:

 <button name="cancel_voucher" string="Cancel Voucher" type="object" states="posted" confirm="Are you sure you want to unreconcile this record?"/>

示例代码:

        <!-- This general view is used in
Invoicing - Journal Entries - Journal Vouchers -->
<record model="ir.ui.view" id="view_voucher_form">
<field name="name">account.voucher.form</field>
<field name="model">account.voucher</field>
<field name="arch" type="xml">
<form string="Accounting Voucher" version="7.0">
<header>
<button name="proforma_voucher" string="Post" states="draft" class="oe_highlight"/>
<button name="cancel_voucher" string="Cancel Voucher" type="object" states="posted" confirm="Are you sure you want to unreconcile this record?"/>
<button name="cancel_voucher" string="Cancel Voucher" states="draft,proforma" />
<button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft"/>
<field name="state" widget="statusbar" statusbar_visible="draft,posted" statusbar_colors='{"proforma":"blue"}'/>
</header>
<sheet string="Accounting Voucher">
<group col="4" colspan="4">
<field name="partner_id" required="1" on_change="onchange_journal_voucher(line_ids, tax_id, amount, partner_id, journal_id, type)"/>
<field name="date" on_change="onchange_date(date, currency_id, payment_rate_currency_id, amount, company_id)"/>
<field name="journal_id" widget="selection" on_change="onchange_journal_voucher(line_ids, tax_id, amount, partner_id, journal_id, type)"/>
<field name="type" required="1"/>
<field name="name" colspan="2"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
<field name="reference"/>
<field name="number"/>
<field name="currency_id" groups="base.group_multi_currency"/>
<field name="account_id" widget="selection" invisible="True"/>
<field name="payment_rate_currency_id" invisible="1"/>
</group>
<notebook colspan="4">
<page string="Voucher Entry">
<field name="line_ids" on_change="onchange_price(line_ids, tax_id, partner_id)" context="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}">
<tree string="Voucher Items" editable="bottom">
<field name="account_id"/>
<field name="name"/>
<field name="amount" sum="Total Amount"/>
<field name="type"/>
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
</tree>
</field>
<group>
<field name="narration" nolabel="1" placeholder="Internal Notes"/>
<group class="oe_subtotal_footer oe_right" attrs="{'invisible':[('type','in',['payment', 'receipt', False])]}">
<field name="tax_id" on_change="onchange_price(line_ids, tax_id, partner_id)" widget="selection" nolabel="1"/>
<field name="tax_amount" nolabel="1"/>
<div class="oe_subtotal_footer_separator">
<label for="amount"/>
<button type="object" icon="terp-stock_format-scientific" name="compute_tax" class="oe_link oe_edit_only" string="(Update)" attrs="{'invisible': [('state','!=','draft')]}"/>
</div>
<field name="amount" class="oe_subtotal_footer_separator" nolabel="1"/>
</group>
</group>
</page>
<page string="Journal Items" attrs="{'invisible': [('state','!=','posted')]}">
<group col="4">
<field name="period_id"/>
<field name="audit"/>
</group>
<field name="move_ids" readonly="1">
<tree string="Journal Items">
<field name="move_id"/>
<field name="ref"/>
<field name="date"/>
<field name="statement_id"/>
<field name="partner_id"/>
<field name="account_id"/>
<field name="name"/>
<field name="debit"/>
<field name="credit"/>
<field name="state"/>
<field name="reconcile_id"/>
</tree>
</field>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>

openerp学习笔记 错误、警告、提示、确认信息显示的更多相关文章

  1. Entity Framework学习笔记——错误汇总

    之前的小项目做完了,到了总结经验和更新学习笔记的时间了.开始正题之前先啰嗦一下,对之前的学习目标进行一个调整:“根据代码生成表”与“生成数据库脚本和变更脚本”合并为“Code First模式日常使用篇 ...

  2. C#学习笔记3:提示“截断字符串或二进制数据”错误解决方法

    1.调试程序如出现“截断字符串或二进制数据”的关于数据库的错误,可以先试一试修改数据库中字符定义的长度. 2.使用ManualResetEvent前需导入 命名空间System.Threading; ...

  3. openerp学习笔记 tree视图增加复选处理按钮

    wizard:用于确认或选择 wizard/sale_multi_action.py # -*- encoding: utf-8 -*-from openerp.osv import fields, ...

  4. JavaScript高级程序设计学习笔记--错误处理与调试

    try-catch语句 只要代码中包含finally子句,则无论try或catch语句块中包含什么代码--甚至return语句,都不会阻止finally子句的执行,来看下面这个函数: function ...

  5. openerp学习笔记 调用工作流

    获取工作流服务:wf_service = netsvc.LocalService("workflow")删除对象对应记录的工作流:wf_service.trg_delete(uid ...

  6. openerp学习笔记 跟踪状态,记录日志,发送消息

    跟踪状态基础数据: kl_qingjd/kl_qingjd_data.xml <?xml version="1.0"?><openerp>    <d ...

  7. javascript学习笔记——chrome等提示找不到“getElementsByTagName”的一种解决方法

    最近学习是写了一个小网页,前台有个下拉框是通过后天的xml配置的,在写好代码后使用发现在IE9以及之前的IE浏览器都可以正常获取,但是IE10,chrome和firefox都会在获取一个标签时报get ...

  8. Tomcat学习笔记 - 错误日志 - Tomcat访问Manager apps出现401 Unauthorized错误

    原因是配置文件中未指定管理员身份. 打开tomcat>conf>tomcat-user.xml文件,添加如下代码: <role rolename="admin-gui&qu ...

  9. Tomcat学习笔记 - 错误日志 - Tomcat安装版安装后第二次启动后闪退(转)-- javac不是内部或外部命令 -- 配置java环境教程

    如果安装成功并且安装完成第一次启动是成功的,第二次就闪退的话,原因之一是没有配置java的环境.在网上找的配制方法有很多错误,测试javac命令时候会提示不是内部或外部命令,找到一个正确的教程.如下, ...

随机推荐

  1. Dapper ORM 用法

    假如你喜欢原生的Sql语句,又喜欢ORM的简单,那你一定会喜欢上Dapper这款ROM.Dapper的优势:1,Dapper是一个轻型的ORM类.代码就一个SqlMapper.cs文件,编译后就40K ...

  2. 【Shell脚本学习3】什么时候使用Shell

    因为Shell似乎是各UNIX系统之间通用的功能,并且经过了POSIX的标准化.因此,Shell脚本只要“用心写”一次,即可应用到很多系统上.因此,之所以要使用Shell脚本是基于: 简单性:Shel ...

  3. VS2013 添加文件头部注释模板

    在看视频的时候发现,视频中每次新建一个类文件 都会自动生成一串 头部的注释:

  4. Oracle基础 动态SQL语句

    一.静态SQL和动态SQL的概念. 1.静态SQL 静态SQL是我们常用的使用SQL语句的方式,就是编写PL/SQL时,SQL语句已经编写好了.因为静态SQL是在编写程序时就确定了,我们只能使用SQL ...

  5. HDU 1087 Super Jumping! Jumping! Jumping! (DP)

    C - Super Jumping! Jumping! Jumping! Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format: ...

  6. Jquery事件委托之Safari

    什么是事件委托 事件委托是Jquery中一种事件绑定的方式,不同于常见的事件绑定方式将事件绑定在目标元素上,而是将事件绑定在父级元素上通过事件冒泡来执行绑定函数. //常见的事件绑定(Jquery) ...

  7. CSS中的文本属性

    本文总结一下CSS中关于文字的相关属性,最后给出实例. CSS基础文字属性 文字的基础属性主要包括:字体.颜色和文本.除去颜色color的属性外,字体和文本的相关属性可以权威参考: CSS 文本属性( ...

  8. CSS其他

    1.元素的宽度由内容撑开 display:inline;——不支持高度 display:inline-block;——在IE6下,不支持块标签 float position:absolute——每项设 ...

  9. 默认样式重置 (css reset)

    body,p,h1,h2,h3,h4,h5,h6,dl,dd,t{margin:0; font-size:12px;/* font-family:XX; */} ol,ul{list-style:no ...

  10. 设置ORACLE数据库游标大小

    先用超级管理员(sys)登陆服务器: sqlplus "sys/***@orcl as sysdba" 连接到:Oracle 查看ORACLE最大游标数: SQL> show ...