Hello, in v14 I am trying to show a string "aggregate" in the group by on the front end. In the backend I defined.
category_name = fields.Char(group_operator='array_agg')
@api.model
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
"""
Override read_group to display the first category of each group
"""
res = super().read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
report_lines = self.env['my_module.my_model']
for line in res:
if '__domain' in line:
report_lines = self.search(line['__domain'])
if 'category_name' in fields:
line['category_name'] = report_lines[0].category_name
return res
If I go to addons/web/static/src/js/views/basic/basic_model.js
and edit the following line
const AGGREGATABLE_TYPES = ['float', 'integer', 'monetary'];Into the following
const AGGREGATABLE_TYPES = ['float', 'integer', 'monetary', 'char'];
My view displays the aggregate type.
How can I add this functionality into my module? I have added an xml template inheritance to load my js file but that is as far as I've gotten. I cannot access the content of the original basic_model.js to do anything.
Another less elegant solution would be to override the _readGroup function and redeclare another list inside it with the types I want to use, then use that one instead. I am thinking that since we are dealing with a const, it might be necesary to work around it.
JavaScript is not my strong point and I have spent hours on this, please help me