diff --git a/odoo/addons/test_read_group/tests/test_private_read_group.py b/odoo/addons/test_read_group/tests/test_private_read_group.py index 5750bdba9ab..82d085d3ae7 100644 --- a/odoo/addons/test_read_group/tests/test_private_read_group.py +++ b/odoo/addons/test_read_group/tests/test_private_read_group.py @@ -312,19 +312,22 @@ class TestPrivateReadGroup(common.TransactionCase): ) def test_malformed_params(self): - Model = self.env['test_read_group.fill_temporal'] + Model = self.env['test_read_group.order.line'] # Test malformed groupby clause with self.assertRaises(ValueError): - Model._read_group([], ['date:bad_granularity']) + Model._read_group([], ['create_date:bad_granularity']) with self.assertRaises(ValueError): - Model._read_group([], ['Other stuff date:week']) + Model._read_group([], ['Other stuff create_date:week']) with self.assertRaises(ValueError): - Model._read_group([], ['date']) # No granularity + Model._read_group([], ['create_date']) # No granularity with self.assertRaises(ValueError): - Model._read_group([], ['"date:week']) + Model._read_group([], ['"create_date:week']) + + with self.assertRaises(ValueError): + Model._read_group([], ['order_id.id']) # Test malformed aggregate clause with self.assertRaises(ValueError): @@ -348,6 +351,9 @@ class TestPrivateReadGroup(common.TransactionCase): with self.assertRaises(ValueError): Model._read_group([], aggregates=['label:sum(value)']) + with self.assertWarns(Warning): + Model._read_group([], aggregates=['order_id.create_date:min']) + # Test malformed having clause with self.assertRaises(ValueError): Model._read_group([], ['value'], having=[('__count', '>')]) diff --git a/odoo/models.py b/odoo/models.py index 5ce03fa100c..d56fc811ca0 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -1954,6 +1954,8 @@ class BaseModel(metaclass=MetaModel): field = self._fields[fname] if func == 'recordset' and not (field.relational or fname == 'id'): raise ValueError(f"Aggregate method {func!r} can be only used on relational field (or id) (for {aggregate_spec!r}).") + if property_name and field.type != 'property': + warnings.warn(f"Ignore the {property_name!r} part of {aggregate_spec!r}, this notation is reserved for the Property field") sql_field = self._field_to_sql(self._table, access_fname, query) sql_expr = READ_GROUP_AGGREGATE[func](self._table, sql_field)