Tuesday, May 2, 2023
1 change · master
New functionality added to Odoo
This change adds a way to filter grouped totals after they are calculated, similar to how reporting tools filter summary results. It helps businesses get cleaner reports, such as excluding customers whose transactions cancel out to zero, without changing the underlying data selection.
Original PR description
Description of the issue/feature this PR addresses:
Having Clause in read_group Function
Current behavior before PR:
Let's say we have some records:
id | partner_id | balance
1 | 10 | 1000
2 | 10 | -1000
3 | 11 | 500
4 | 11 | 200
Currently, only 'WHERE' clauses are provided. If we call the read_group(domain=[('balance','!=',0)], fields=['partner_id', 'balance'], groupby=['partner_id']) , then we'll get:
partner_id | balance
10 | 0
11 | 700
Desired behavior after PR is merged:
Sometimes we need the read_group function to filter as the 'HAVING' clause in SQL do and expect something like read_group(domain=[], fields=['partner_id', 'balance'], groupby=['partner_id'], having_clause_domain=[('balance','!=',0)]) so we can get:
partner_id | balance
11 | 700
--
I confirm I have signed the CLA and read the PR guidelines at [www.odoo.com/submit-pr](http://www.odoo.com/submit-pr)