[FIX] web: fix bad groupby as str instead of list

A mistake introduced in  234db70d86, the
`groupby` of  `_read_group` should be list/tuple of  `str`, not a `str`.

closes odoo/odoo#119400

Signed-off-by: Raphael Collet <rco@odoo.com>
This commit is contained in:
Rémy Voet (ryv)
2023-04-22 06:53:49 +02:00
committed by Raphael Collet
parent 8f971c045c
commit 70fd18ef67
3 changed files with 43 additions and 1 deletions
+1 -1
View File
@@ -185,7 +185,7 @@ class Base(models.AbstractModel):
elif limit and len(groups) == limit:
length = limit + len(self._read_group(
domain,
groupby=groupby if not lazy else groupby[0],
groupby=groupby if not lazy else [groupby[0]],
offset=limit,
order=orderby,
))
@@ -15,3 +15,4 @@ from . import test_domain
from . import test_schema
from . import test_company_checks
from . import test_unity_read
from . import test_web_read_group
@@ -0,0 +1,41 @@
from odoo.tests.common import TransactionCase
class TestWebReadGroup(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env['test_new_api.multi.tag'].create([
{'name': 'one'},
{'name': 'two'},
{'name': 'two'},
{'name': 'there'},
{'name': 'there'},
{'name': 'there'},
])
def test_web_read_group_limit_not_reached(self):
result = self.env['test_new_api.multi.tag'].web_read_group(
[], ['__count'], ['name'], limit=80,
)
self.assertEqual(result, {
'groups': [
{'name': 'one', 'name_count': 1, '__domain': [('name', '=', 'one')]},
{'name': 'there', 'name_count': 3, '__domain': [('name', '=', 'there')]},
{'name': 'two', 'name_count': 2, '__domain': [('name', '=', 'two')]},
],
'length': 3,
})
def test_web_read_group_limit_reached(self):
result = self.env['test_new_api.multi.tag'].web_read_group(
[], ['__count'], ['name'], limit=2,
)
self.assertEqual(result, {
'groups': [
{'name': 'one', 'name_count': 1, '__domain': [('name', '=', 'one')]},
{'name': 'there', 'name_count': 3, '__domain': [('name', '=', 'there')]},
],
'length': 3,
})