Skip to Content
Menu
This question has been flagged
1 Reply
3666 Views

Impacted versions: Odoo 13 CE

Steps to reproduce: Create a custom module then add a model with computed field with store=True. Call the read_group method upon this model with the computed field within broupby fields. Here the field's declaration

type_id = fields.Many2one('my_module.custom.model', string='Type', compute='_compute_type_id',
store=True,tracking=True, check_company=True)
Current behavior: Get following error

Odoo Server Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 619, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 309, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/usr/lib/python3/dist-packages/odoo/http.py", line 664, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 345, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 93, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 338, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 909, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 510, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1319, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1311, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 391, in call_kw
result = _call_kw_model(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 364, in _call_kw_model
result = method(recs, *args, **kwargs)
File "/usr/src/app/custom_addons/asb_mgmt_reporting/models/dashboard.py", line 64, in get_dashboard_data
groupby='type_id')
File "/usr/lib/python3/dist-packages/odoo/models.py", line 2132, in read_group
result = self._read_group_raw(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 2169, in _read_group_raw
assert gb_field.store and gb_field.column_type, "Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True"
AssertionError: Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True

Avatar
Discard
Best Answer

Hi, 

i'm confused where the function get_dashboard_data is called ? i can tell, based on the logs, that read_group is called inside of it ?


Can you please share your compute function code so that we can help  more?

Thanks.


Avatar
Discard
Author

1. get_dashboard_data is called from a javascript file

2. Yes read_group is called within the get_dashboard_data function

IMHO the message

Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True

is misleading because from I understand you cannot use a related or computed field in groupby except if it has the attribute store set to True.

Here is the declaration of the field causing the issue

type_id = fields.Many2one('my_module.custom.model', string='Type', compute='_compute_type_id',

store=True,tracking=True, check_company=True)

As you can see it has the attribute store set to True.

I have opened an issue on github you can check it with the following link.

https://github.com/odoo/odoo/issues/73189

Did you check that your field does exist in your database ? ( do you see a column for your field in the concerned model ? )

Author

Yes the field type_id is store in the database

I would like to show you a screenshot but I cannot find a way to upload a picture here

at this moment, nothing seems wrong:

You have a compute field with store=True

you upgrade module, then you go to your dashboard where function get_dashboard_data is triggered.

it should run without any problem related to your computed field.

Maybe if you try this in a new DB, you can check if you still have the same problem..

OKAY i'll give it a try

Related Posts Replies Views Activity
0
Aug 24
158
1
Jul 24
724
2
Sep 23
2100
1
Dec 22
1079
3
Nov 22
2881