-
-
Save litnimax/bcc34097456bfec787d8a5af8d3c8335 to your computer and use it in GitHub Desktop.
Odoo many2many groupby example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@api.model | |
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True): | |
if not '_context_' in groupby: | |
return super(Task, self).read_group(domain, fields, groupby, | |
offset, limit, orderby, lazy) | |
else: | |
# Get the list of contexts | |
res = [] | |
for c in self.env['nibbana.context'].search( | |
[('create_uid','=', self.env.user.id)]): | |
count = self.env['nibbana.task'].search_count([('context','in',c.id)]) | |
res.append({ | |
'_context_': c.name, | |
'_context__count': count, | |
'__domain': expression.AND([domain, [('context','in', c.id)]]) | |
}) | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment