【问题标题】:How to group by based on month in odoo 11?如何在odoo 11中按月份分组?
【发布时间】:2021-03-05 10:59:30
【问题描述】:

如何在odoo 11中按月份分组?

<filter string="PO Date" icon="terp-gtk-select-all" domain="[]" context="{'group_by':'order_date'}"/>

<filter string="PO Date"  domain="[]" context="{'group_by':'order_date'}"/>

尝试使用上述两种语法但不起作用

【问题讨论】:

    标签: odoo odoo-10 odoo-9 odoo-11 odoo-12


    【解决方案1】:

    您可以根据月份在采购订单组中执行此操作。

    <group expand="0" string="Group By">
        <filter string="Order Date" domain="[]" context="{'group_by':'date_order'}"/>
    </group>
    

    【讨论】:

      【解决方案2】:

      您可以在month上专门制作groupby

      例子:

      <filter string="Expected Closing" context="{'group_by':'date_deadline:month'}" name="date_deadline" help="Expiration Closing Month"/>
      

      这是否也可以实现值为'day', 'week', 'month', 'quarter' or 'year'

      @api.model
      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 supported
                  are '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, for
                               overriding the natural sort ordering of the
                               groups, 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 are
                  done 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
          """
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-29
        • 1970-01-01
        • 1970-01-01
        • 2014-01-30
        • 2018-02-11
        相关资源
        最近更新 更多