File: test_gbf.py

package info (click to toggle)
oca-core 11.0.20180730-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 509,684 kB
  • sloc: xml: 258,806; python: 164,081; sql: 217; sh: 92; makefile: 16
file content (22 lines) | stat: -rw-r--r-- 865 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo.tests import common

class TestGBF(common.TransactionCase):
    def test_group_by_full(self):
        Sub = self.env['test_converter.test_model.sub']
        TM = self.env['test_converter.test_model']

        # remove all existing subs (no need to panic, it will be rollbacked...)
        Sub.search([]).unlink()

        subs_ids = [Sub.create({'name': 'sub%d' % i}).id for i in range(5)]
        tm_ids = [TM.create({'many2one': subs_ids[i]}).id for i in range(3)]

        domain = [('id', 'in', tuple(tm_ids))]
        rg = TM.read_group(domain, fields=['many2one'], groupby=['many2one'])

        self.assertEqual(len(rg), len(subs_ids))
        rg_subs = sorted(g['many2one'][0] for g in rg)
        self.assertListEqual(rg_subs, sorted(subs_ids))