File: test_web_read_group.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (27 lines) | stat: -rw-r--r-- 992 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from odoo import fields
from odoo.tests import common


@common.tagged('post_install', '-at_install')
class TestWebReadGroup(common.TransactionCase):

    def test_web_read_group_with_date_groupby_and_limit(self):
        res_partner_model_id = self.env["ir.model"].search([("model", "=", "res.partner")]).id
        self.env["ir.model.fields"].create({
            "name": "x_date",
            "ttype": "date",
            "model": "res.partner",
            "model_id": res_partner_model_id,
        })
        first, second = self.env["res.partner"].create([
            {
                "name": "first",
                "x_date": fields.Date.to_date("2021-06-01")
            },
            {
                "name": "second",
                "x_date": fields.Date.to_date("2021-07-01")
            }
        ])
        groups = self.env["res.partner"].web_read_group([["id", "in", [first.id, second.id]]], [], groupby=["x_date"], limit=1)
        self.assertEqual(groups["length"], 2)