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 ...
随机推荐
- 三模数NTT模板
求两个多项式的卷积对任意数p取模 两个好记的FNT模数: 5*2^25+1 7*2^26+1 原根都为3 //Achen #include<algorithm> #include<i ...
- Taro框架---左滑动删除
index.js import Taro, { Component } from '@tarojs/taro' import { View,ScrollView } from '@tarojs/com ...
- springMVC 400 错误
1. 今天发现一个奇葩的问题, springMVC出现400错误, 查了很久发现是因为一个参数为int型,而前台传得是String. 这是bug么.
- XML、JSON、ProtocolBuffer特点比较
XML JSON PB Lua 数据结构支持 复杂结构 简单结构 较复杂结构 复杂结构 数据保存方式 文本 文本 二进制 文本 数据保存大小 大 一般 小 一般 解析效率 慢 一般 快 稍快 语言支持 ...
- Identifying a Blocking Query After the Issuing Session Becomes Idle
Identifying a Blocking Query After the Issuing Session Becomes Idle #查看阻塞信息 select * from sys.innodb ...
- 爬虫所需要的文档和自动化文本driver下载地址,以及制作词云的文档,api等
Scrapy1.7.3文档 webdriver文档 webdriver下载地址 Chrom各版本下载地址 词云1.5文档 selenium中文文档 vue数据可视化文档 element开发组件 其他好 ...
- python常用包及功能介绍
1.NumPy数值计算 NumPy是使用Python进行科学计算的基础包,Numpy可以提供数组支持以及相应的高效处理函数,是Python数据分析的基础,也是SciPy.Pandas等数据处理和科学计 ...
- Python - Virtualenv 创建虚拟环境
Virtualenv 回到顶部 为了解决各个项目的共同依赖同一个环境,造成版本冲突等,virtualenv创建一个干净的环境,在这个环境下,进行Python项目的开发等,就成为一个个独立的项目,从而避 ...
- HttpServletRequest的方法详细说明
1.Java 部分request.getHeader()详细说明 == JAVA 部分request.getHeader() 详细说明== System.out.println("rotoc ...
- ON_WM_TIMER() void (__cdecl xx::* )(UINT)”转换为“void (__cdecl CWnd::* )(UINT_PTR)
ON_WM_TIMER()在编译器从32位转换为64位的时候, 出现的问题; class CFlatComboBox : public CComboBox (基类为CWnd) 为了重载CWnd的 ...