-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] base: read_group date part number granularity #159528
[IMP] base: read_group date part number granularity #159528
Conversation
2de9fd5
to
d0804a5
Compare
d0804a5
to
f592a58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @VincentSchippefilt
It looks very promising, I already left some comments.
340b80a
to
6a28ede
Compare
6a28ede
to
128ab4b
Compare
128ab4b
to
f01cb3e
Compare
Hello @odoo/rd-security, I wouldn't mind a good review as I add a "new" SQL operation, using |
references odoo/odoo#159528 Task: 3836802
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a naming perspective I'm not sure about "relative", my first thought reading the PR title was that it was going to be a sliding window (increments relative to now).
SQL seems fine.
ba1f330
to
917f40d
Compare
robodoo r+ |
fdd1169
to
5cc028d
Compare
When doing reporting, especially in spreadsheet, it is usefull to be able to group dates by different granularities. Today, Odoo supports Year, Quarter, Month, Week and Day. Those granularities are "absolute" in the sence that b.e. Quarter will return "Q1 2021" In this commit, I introduce new granularities. These granularities will span different years and collect the all dates with specific month, quarter or week: "month_number", will return the month of the year of all dates: a number between 1 and 12; "quarter_number", will return the quarter of the year: a number between 1 and 4; "iso_week_number", will return the week of the year, according to ISO 8601: a number between 1 and 53, etc. Usage: In read_group or _read_group, the group_by and order by can now be ['date_field:month_number']. In a domain, you can write [('date_field.month_number','=',2)]. Note that read_group will return a __domain containing the correct relative granularity. Example: self.env["my_model"].create(({"value": "1", "date": "2021-02-09"}, {"value": "2", "date": "2021-06-01"}, {"value": "3", "date": "2022-02-01"})) self.env["my_model"].read_group([],fields=['date', 'value'],groupby=['date:month_number']) --> [ { 'date:month_number': 2.0, 'date_count': 2, 'value': 4, '__domain': [('date.month_number', '=', 2.0)] }, { 'date:month_number': 6.0, 'date_count': 1, 'value': 2, '__domain': [('date.month_number', '=', 6.0)] } ]) Task: 3836802
5cc028d
to
d8fe54d
Compare
robodoo r+ |
When doing reporting, especially in spreadsheet, it is usefull to be able to group dates by different granularities. Today, Odoo supports Year, Quarter, Month, Week and Day. Those granularities are "absolute" in the sence that b.e. Quarter will return "Q1 2021" In this commit, I introduce new granularities. These granularities will span different years and collect the all dates with specific month, quarter or week: "month_number", will return the month of the year of all dates: a number between 1 and 12; "quarter_number", will return the quarter of the year: a number between 1 and 4; "iso_week_number", will return the week of the year, according to ISO 8601: a number between 1 and 53, etc. Usage: In read_group or _read_group, the group_by and order by can now be ['date_field:month_number']. In a domain, you can write [('date_field.month_number','=',2)]. Note that read_group will return a __domain containing the correct relative granularity. Example: self.env["my_model"].create(({"value": "1", "date": "2021-02-09"}, {"value": "2", "date": "2021-06-01"}, {"value": "3", "date": "2022-02-01"})) self.env["my_model"].read_group([],fields=['date', 'value'],groupby=['date:month_number']) --> [ { 'date:month_number': 2.0, 'date_count': 2, 'value': 4, '__domain': [('date.month_number', '=', 2.0)] }, { 'date:month_number': 6.0, 'date_count': 1, 'value': 2, '__domain': [('date.month_number', '=', 6.0)] } ]) closes #159528 Task: 3836802 Related: odoo/documentation#8447 Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
references odoo/odoo#159528 closes #8447 Task: 3836802 Related: odoo/odoo#159528 Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
This commit adds the support for the new granularities added in odoo#159528. Task: 3899604
This commit adds the support for the new granularities added in odoo#159528. Task: 3899604
This commit adds the support for the new granularities added in #159528. Task: 3899604 Part-of: #172202 Related: odoo/enterprise#66209 Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
When doing reporting, especially in spreadsheet, it is usefull to be able
to group dates by different granularities.
Today, Odoo supports Year, Quarter, Month, Week and Day. Those granularities are
"absolute" in the sence that b.e. Quarter will return "Q1 2021"
In this commit, I introduce new granularities.
These granularities will span different years and collect the all dates with specific month, quarter or week:
"month_number", will return the month of the year of all dates: a number between 1 and 12;
"quarter_number", will return the quarter of the year: a number between 1 and 4;
"week_number", will return the week of the year, according to ISO 8601: a number between 1 and 53
Usage:
In read_group or _read_group, the group_by and order by can now be ['date_field:month_number'].
In a domain, you can write [('date_field.month_number','=',2)].
Note that read_group will return a __domain containing the correct relative granularity.
Example:
documentation PR: odoo/documentation#8447
Task: 3836802
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr