289
289
{'name': 'Alice', 'login': 'alice', 'color': 1, 'function': 'Friend'},
290
290
{'name': 'Bob', 'login': 'bob', 'color': 2, 'function': 'Friend'},
291
291
{'name': 'Eve', 'login': 'eve', 'color': 3, 'function': 'Eavesdropper'},
292
{'name': 'Nab', 'login': 'nab', 'color': 2, 'function': '5$ Wrench'},
293
294
self.res_users.create(cr, uid, user_data)
298
299
self.assertIn('color', group_data, "Aggregated data for the column 'color' is not present in read_group return values")
299
300
self.assertEqual(group_data['color'], 3, "Incorrect sum for aggregated data for the column 'color'")
302
groups_data = self.res_users.read_group(cr, uid, domain=[('login', 'in', ('alice', 'bob', 'eve'))], fields=['name', 'color'], groupby='name', orderby='name DESC, color asc')
303
self.assertEqual(len(groups_data), 3, "Incorrect number of results when grouping on a field")
304
self.assertEqual([user['name'] for user in groups_data], ['Eve', 'Bob', 'Alice'], 'Incorrect ordering of the list')
306
groups_data = self.res_users.read_group(cr, uid, domain=[('login', 'in', ('alice', 'bob', 'eve', 'nab'))], fields=['function', 'color'], groupby='function', orderby='color ASC')
307
self.assertEqual(len(groups_data), 3, "Incorrect number of results when grouping on a field")
308
self.assertEqual(groups_data, sorted(groups_data, key=lambda x: x['color']), 'Incorrect ordering of the list')
301
310
class test_partner_recursion(common.TransactionCase):