Odoo Documentation : Recordsets
Other recordset operations
Recordsets are iterable(可迭代的) so the usual Python tools are available for transformation (map(), sorted(), ifilter(), ...) however these return either a list or an iterator, removing the ability(能力) to call methods on their result, or to use set operations.
Recordsets therefore provide these operations returning recordsets themselves (when possible):
filtered()-
returns a recordset containing only records satisfying the provided predicate function(判定函数). The predicate can also be a string to filter by a field being true or false:
# only keep records whose company is the current user's
records.filtered(lambda r: r.company_id == user.company_id) # only keep records whose partner is a company
records.filtered("partner_id.is_company") sorted()-
returns a recordset sorted by the provided key function. If no key is provided, use the model's default sort order:
# sort records by name
records.sorted(key=lambda r: r.name) mapped()-
applies the provided function to each record in the recordset, returns a recordset if the results are recordsets:
# returns a list of summing two fields for each record in the set
records.mapped(lambda r: r.field1 + r.field2)The provided function can be a string to get field values:
# returns a list of names
records.mapped('name') # returns a recordset of partners
record.mapped('partner_id') # returns the union of all partner banks, with duplicates removed
record.mapped('partner_id.bank_ids')
Odoo Documentation : Recordsets的更多相关文章
- Odoo Documentation : Environment
Environment The Environment stores various contextual data(上下文数据 ) used by the ORM: the database cur ...
- Odoo Documentation : Fields
Fields Basic fields class openerp.fields.Field(string=None, **kwargs) The field descriptor contains ...
- Defining custom settings in Odoo
Unfortunately Odoo documentation doesn’t seem to include any information about adding new configurat ...
- odoo配置界面设置字段默认值
转自国外牛人博客:http://ludwiktrammer.github.io/odoo/custom-settings-odoo.html Defining custom settings in O ...
- odoo 有哪些文档资源
// openbook [覆盖 openerp 7 及之前版本] https://doc.odoo.com/ // 最新的 odoo documentation user[覆盖 odoo 9] ...
- 【原创】Odoo开发文档学习之:ORM API接口(ORM API)(边Google翻译边学习)
官方ORM API开发文档:https://www.odoo.com/documentation/10.0/reference/orm.html Recordsets(记录集) New in vers ...
- Odoo中的Javascript单元测试
前端页面利用QUnit进行单元测试,本文参考官方文档:https://www.odoo.com/documentation/8.0/reference/javascript.html 访问/web/t ...
- ODOO 源代码安装要求
ODOO 源代码安装要求 ref:http://www.odoo.com/documentation/10.0/setup/install.html#setup-install-source pyth ...
- 配置Windows 2008 R2 64位 Odoo 8.0 源码PyCharm开发调试环境
安装过程中,需要互联网连接下载python依赖库: 1.安装: Windows Server 2008 R2 x64标准版 2.安装: Python 2.7.10 amd64 到C:\Python27 ...
随机推荐
- CSS3——2D变形和3D变形
2D变形(CSS3) transform transform是CSS3中具有颠覆性的特征之一,可以实现元素的位移.旋转.倾斜.缩放,甚至支持矩阵方式,配合过渡和即将学习的动画知识,可以取代大量之前只能 ...
- 0918CSP-S模拟测试赛后总结
14名.110分.可以算是几次大落之后的一次小小的崛起?? 然而sdfz的开挂选手AK了啊…… T2重测前rank7我就高兴地像个傻子??也不看看这次T1是个什么题. 实力还是不行.一眼秒掉了简单题, ...
- 没有找到mfc100.dll
转自VC错误:http://www.vcerror.com/?p=86 问题描述: 生成的exe文件在编译的时候会提示"没有找到mfc100.dll",这个时候需要更改配置为静态编 ...
- YARN 原理简介
YARN 组件 参考:Spark on Yarn | Spark,从入门到精通 YARN 采用 Master/Slave结构 ,包含ResourceManager 和 NodeManager Reso ...
- JAVA_ArrayList和HashSet
ArrayList ArrayList在Java中主要是以线性表的形式进行存储,其本质是数组,不过相对于数组的长度不可变这一缺点,其实行了长度可变策略,使你在使用时,感觉到其就是一个无限长度的数组,而 ...
- 解决div设置浮动,高度消失
给包围 浮动的层 加清除浮动样式,样式要兼容的用下面的代码.clearfix {*zoom:1; clear:both;}.clearfix:after{content:".";d ...
- cv2 & PIL(pillow)显示图像
= OpenCV和PIL中显示图像方式不一样,且支持的格式也不同 = cv在显示图像时是自定义的显示窗口,而PIL中显示是调用操作系统中的默认打开程序 如: import cv2 im = cv2.i ...
- UMP系统架构 Zookeeper
- 显示和隐藏(display属性)none或block
显示和隐藏(display属性) 网页中经常会看到显示和隐藏的效果,可通过display属性来设置. 语法: Object.style.display = value 注意:Object是获取的元素对 ...
- 如何玩转跨库Join?跨数据库实例查询应用实践
背景 随着业务复杂程度的提高.数据规模的增长,越来越多的公司选择对其在线业务数据库进行垂直或水平拆分,甚至选择不同的数据库类型以满足其业务需求.原本在同一数据库实例里就能实现的SQL查询,现在需要跨多 ...