read_group函数

read_group中英文注释解释

    def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):"""Get the list of records in list view grouped by the given ``groupby`` fields:param domain: list specifying search criteria [['field_name', 'operator', 'value'], ...]:param list fields: list of fields present in the list view specified on the object:param list groupby: list of groupby descriptions by which the records will be grouped.  A groupby description is either a field (then it will be grouped by that field)or a string 'field:groupby_function'.  Right now, the only functions supportedare 'day', 'week', 'month', 'quarter' or 'year', and they only make sense for date/datetime fields.:param int offset: optional number of records to skip:param int limit: optional max number of records to return:param list orderby: optional ``order by`` specification, foroverriding the natural sort ordering of thegroups, see also :py:meth:`~osv.osv.osv.search`(supported only for many2one fields currently):param bool lazy: if true, the results are only grouped by the first groupby and the remaining groupbys are put in the __context key.  If false, all the groupbys aredone in one call.:return: list of dictionaries(one dictionary for each record) containing:* the values of fields grouped by the fields in ``groupby`` argument* __domain: list of tuples specifying the search criteria* __context: dictionary with argument like ``groupby``:rtype: [{'field_name_1': value, ...]:raise AccessError: * if user has no read rights on the requested object* if user tries to bypass access rules for read on the requested object"""result = self._read_group_raw(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)groupby = [groupby] if isinstance(groupby, basestring) else list(OrderedSet(groupby))dt = [f for f in groupbyif self._fields[f.split(':')[0]].type in ('date', 'datetime')]# iterate on all results and replace the "full" date/datetime value# (range, label) by just the formatted label, in-placefor group in result:for df in dt:# could group on a date(time) field which is empty in some# records, in which case as with m2o the _raw value will be# `False` instead of a (value, label) pair. In that case,# leave the `False` value aloneif group.get(df):group[df] = group[df][1]return result

获取按给定groupby字段分组的列表视图中的记录列表

:param domain:list指定搜索条件[[‘field_name’,‘operator’,‘value’],…]
:param list fields:对象上指定的列表视图中存在的字段列表
:param list groupby:将记录分组的groupby描述列表。
groupby描述是一个字段(然后它将按该字段分组)
或字符串’field:groupby_function’。现在,支持的唯一功能
是’天’,‘周’,‘月’,‘季’或’年’,它们只是有意义的
日期/日期时间字段。
:param int offset:要跳过的可选记录数
:param int limit:可选的最大返回记录数
:param list orderby:可选order by规范,for
重写自然排序顺序
组,另见:py:meth:~osv.osv.osv.search
(目前仅支持多个字段)
:param bool lazy:如果为true,则结果仅按第一个groupby和
剩余的groupbys放在__context键中。如果为false,则所有组都是
在一个电话中完成。
:return:字典列表(每个记录一个字典)包含:

                *由``groupby``参数中的字段分组的字段值* __domain:指定搜索条件的元组列表* __context:带有``groupby``之类的参数的字典:rtype:[{'field_name_1':value,...]:引发AccessError:*如果用户对请求的对象没有读取权限*如果用户试图绕过访问规则以读取请求的对象

我们可以看到对日期中’天’,‘周’,‘月’,'季’或’年’可以进行分组


chart_data = self.env['task_stage_data_analysis'].read_group(domain=
[('project', '=', project_id)], fields=['current_date'],      groupby='current_date:month')

odoo中分组查询函数read_group相关推荐

  1. oracle分组聚合查询,Oracle中分组查询group by用法规则解析

    本篇文章小编给大家分享一下Oracle中分组查询group by用法规则解析,文章介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看. Oracle中group by ...

  2. oracle分类函数总结,oracle中分组排序函数用法

    项目开发中,我们有时会碰到需要分组排序来解决问题的情况,如:1.要求取出按field1分组后,并在每组中按照field2排序:2.亦或更加要求取出1中已经分组排序好的前多少行的数据 这里通过一张表的示 ...

  3. oracle 条件排序函数,oracle中分组排序函数

    项目开发中,我们有时会碰到需要分组排序来解决问题的情况,如:1.要求取出按field1分组后,并在每组中按照field2排序:2.亦或更加要求取出1中已经分组排序好的前多少行的数据 这里通过一张表的示 ...

  4. MapInfo中常用查询函数及用法

    MapInfo中常用查询函数及用法: 函数用途 语法 备注 图层中选点 Str$(obj)="point": Str(String)表示字符串:point表示点: 图层中选线 St ...

  5. php mysql 时间戳查询_mysql中时间查询函数(包括时间戳)

    mysql中时间查询函数(包括时间戳) 这些函数都是MySQL自带的,可以直接使用在PHP写的MySQL查询语句中哦 1-CURDATE()或CURRENT_DATE()和CURTIME()或CURR ...

  6. mysql 函数返回查询结果_MySQL数据库中常用查询函数简介

    MYSQL中的常用函数 count(*)--- 相当于统计表的行数,在统计结果的时候,不会忽略列值为NULL的记录. select count(*) from yinxiong; Count(列名) ...

  7. oracle从入门到精通(4)------运算符,分组查询,函数

    oracle入门到精通(4) --------------------------------------------- 1.运算符 2.分组查询 3.函数 --------------------- ...

  8. mysql 查看数据库函数_MySQL数据库中常用查询函数简介

    MYSQL中的常用函数 count(*)--- 相当于统计表的行数,在统计结果的时候,不会忽略列值为NULL的记录. select count(*) from yinxiong; Count(列名) ...

  9. oracle中按数字大小排序函数,oracle中分组排序函数用法

    项目开发中,我们有时会碰到需要分组排序来解决问题的情况,如: 1.要求取出按field1分组后,并在每组中按照field2排序:2.亦或更加要求取出1中已经分组排序好的前多少行的数据 这里通过一张表的 ...

最新文章

  1. 真分数c语言,C语言列出真分数序列代码及解析
  2. 使用angular5+ionic3+sqlite创建离线app应用
  3. 【笔记】docker核心概念和使用 docker命令
  4. java中数值023是什么类型_【Java 教程(原创)】023.参数传值——引用类型参数的传值...
  5. Quarkus的其他(非标准)CDI功能
  6. Codeforces 213E Two Permutations 线段树 (看题解)
  7. Java局域网对战游戏、天气预报项目
  8. maven的基本命令
  9. 【服务通知】微信小程序服务通知
  10. IT服务台方案:提供完整的业务流程视图
  11. 垃圾收集器回收种类 以及七种垃圾收集器
  12. 废旧电脑改装个人服务器
  13. uniapp ios打包详细步骤
  14. 项目部署常用linux命令(丰富的教程、资源)
  15. 那些从来不用花呗的女孩
  16. 【php毕业设计】基于php+mysql+mvc的网上留言管理系统设计与实现(毕业论文+程序源码)——网上留言管理系统
  17. api有哪些 javasocket_Java原生Socket API
  18. Qt之塔防游戏 c++(一)
  19. php 模板编译类,一个简单的模板类--编译型的(simplet类增强后)_PHP教程
  20. jvm-性能优化专题-jvm最全

热门文章

  1. mybatis-generator自动生成代码插件使用详解
  2. Cisco路由器的安全配置方案
  3. keil编译代码Program Size详解
  4. 应用软件中如何实现多币种自动换算
  5. 软件定义的容错计算机体系,1.4 软件容错技术 - 计算机系统容错技术方法
  6. 搜狗输入法人机交互设计的用户体验
  7. 二手物品交易管理系统
  8. PrimeTime基础命令:get_pins
  9. 学生学籍管理系统包括成绩c语言,学籍管理系统设计C语言代码
  10. excel报表管理系统mysql_教育扶贫数据库管理系统下载安装|教育扶贫数据库管理系统(mysql收集excel表格)官方版下载_v1.0_9号软件下载...