1.odoo的tree视图底部显示合计

tree 视图,底部显示指定字段合计数 ,视图中字段定义上在sum,取自sale.view_order_tree 销售订单 tree 视图

<field name="amount_total" sum="Total Tax Included"/>

2. odoo使用group by分组时显示字段合计  方法是重写read_group方法

https://stackoverflow.com/questions/27536186/how-to-sum-other-columns-when-using-group-by-in-a-tree-view

The key is to overwrite the read_group method of the class:

class your_class(osv.osv):
# ... def read_group(self, cr, uid, domain, fields, groupby, offset=, limit=None, context=None, orderby=False, lazy=True):
res = super(your_class, self).read_group(cr, uid, domain, fields, groupby, offset, limit=limit, context=context, orderby=orderby, lazy=lazy)
if 'amount_pending' in fields:
for line in res:
if '__domain' in line:
lines = self.search(cr, uid, line['__domain'], context=context)
pending_value = 0.0
for current_account in self.browse(cr, uid, lines, context=context):
pending_value += current_account.amount_pending
line['amount_pending'] = pending_value
if 'amount_payed' in fields:
for line in res:
if '__domain' in line:
lines = self.search(cr, uid, line['__domain'], context=context)
payed_value = 0.0
for current_account in self.browse(cr, uid, lines, context=context):
payed_value += current_account.amount_payed
line['amount_payed'] = payed_value
return res

If you want, for example, remove the sum of a column in the group by, you can do something like this:

class your_class(osv.osv):
# ... def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False, lazy=True):
if 'column' in fields:
fields.remove('column')
return super(your_class, self).read_group(cr, uid, domain, fields, groupby, offset, limit=limit, context=context, orderby=orderby, lazy=lazy):

odoo在底部显示指定字段合计和汇总时显示合计的更多相关文章

  1. TextView设置最多显示指定个字符,超过部分显示...(省略号)

    今天在公司遇到一个需求:TextView设置最多显示8个字符,超过部分显示...(省略号),网上找了很多资料,有人说分别设置TextView的android:signature="true& ...

  2. mongodb查询只显示指定字段

    db.COMMODITY_COMMODITY.find( { "areaCode" : "320100" , "backCatalogId" ...

  3. 项目实例——多表关联查询判断A的字段是否在B中,在显示该字段值,不在显示空;B的字段是否在C中,在显示该字段值,不在显示空。

    1.需求: (1)三张表A.B.C  三个表id相同,如果A表中的name在B表中的bname中显示aname值,否则显示空:如果C表中的addr在B表中的tel显示addr,否则显示空 2.实现方式 ...

  4. 用CSS做长度超过长度显示‘...’,当鼠标放上时显示全部内容

    <!DOCTYPE html> <html> <head> <meta name="author" content="Yeeku ...

  5. mgo-后续测试(指定字段,获取id)

    测试完mgo中的DBRef后,想接着测试指定字段的显示,才发现原来采用框架编码,很多问题被隐藏了起来: 1.显示指定字段: 之前在使用mgo时一直是查询全部字段,在mongo终端环境写为如下格式: & ...

  6. 使用AJAX填充<select>标签下拉项,没有显示指定的option项

    newCarInfo.js代码如下: $(function() {     // 获取燃油种类     url = "basicFuelType_queryAll.action"; ...

  7. JS实现类似QQ好友头像hover时显示资料卡的效果

    一.应用场景 鼠标hover弹出div,并且鼠标离开后不能马上隐藏,因为这个div上还有功能入口.比如: 鼠标经过好友列表中的好友头像时显示资料卡的效果 hover时显示二维码 二.实现 用如下这样一 ...

  8. 转:zTree树控件key配置之title:zTree树节点名称过长如何省略显示且鼠标移入节点上能够显示全称

    当树节点的名称有些很长时,全部显示出来显得很拥挤的情况下,我们会想到用省略节点名称来代替,当鼠标移入节点时能够显示该节点的全称.这样我们应该如何做呢? 首先,我们要在树的节点内多增加一个属性用于设置该 ...

  9. gridView RowDataBound事件 鼠标经过行颜色变化及根据字段值显示指定内容

    protected void gvBarInfo_RowDataBound(object sender, GridViewRowEventArgs e)        {            if ...

随机推荐

  1. ArcGIS for Server 的修改IP问题

      ArcGIS for Server 的修改IP问题   1. [arcgisserver@centos6 ~]$ vi /home/arcgisserver/serverconfig/config ...

  2. selenium 之百度搜索,结果列表翻页查询

    selenium之百度搜索,结果列表翻页查询 by:授客 QQ:1033553122 实例:百度搜索,结果列表翻页查询 解决问题:解决selenium driver获取web页面元素时,元素过期问题 ...

  3. mysql索引类型 normal, unique, full text

    问题1:mysql索引类型normal,unique,full text的区别是什么? normal:表示普通索引 unique:表示唯一的,不允许重复的索引,如果该字段信息保证不会重复例如身份证号用 ...

  4. python第四十三天--第三模块考核

    面向对象: 概念:类,实例化,对象,实例 属性: 公有属性:在类中定义 成员属性:在方法中定义 私有属性:在方法中使用 __属性  定义 限制外部访问 方法: 普通方法 类方法: @classmeth ...

  5. [MapReduce_4] MapTask 并发数的决定机制

    0. 说明 介绍 && Map 个数 & Reduce 个数指定 && Map 切片计算 1. 介绍 一个 job 的 Map 阶段并行度由客户端在提交 job ...

  6. [PC]两个蓝牙耳机同时输出相同音源

    需求:和老婆一起玩双人同屏游戏(以撒的结合:抗生),但需要带上蓝牙耳机玩. 设备:2个蓝牙耳机.1个蓝牙接收器.1台Win10系统电脑. 通过关键字搜索出一个解决方案(Output audio to ...

  7. phoneGap使用 (MAC)

    一.安装 ①先安装NodeJS(如果有的就不用安装了) http://nodejs.org/ ②.sudo npm install -g phonegap 需要等待安装完成 ③.检测是否安装成功 no ...

  8. c++11の异步方法 及线程间通信

    1. std::promise 可以用来在线程间提供数据传递. std::future = std::promise.get_future(). 线程中可以对promise赋值std::promise ...

  9. python五十五课——calendar模块

    4.calendar模块: 构造:calendar(year,[w=2,l=1,c=6]):返回year年的完整的日历信息对象 和闰年相关的函数如下: isleap(year):判断year是否是闰年 ...

  10. 一次ASM磁盘空间假装耗尽 ORA-15041: DISKGROUP SPACE EXHAUSTED

    给ASM磁盘新增一块盘进去,ASM_DISK2剩余空间四百多G: SQL> select * from v$asm_diskgroup;   GROUP_NUMBER NAME         ...