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] Order groups by selection declaration order in read_group #75856
Closed
Elkasitu
wants to merge
1
commit into
odoo:master
from
odoo-dev:master-order-read_group-selection-adt
Closed
[IMP] Order groups by selection declaration order in read_group #75856
Elkasitu
wants to merge
1
commit into
odoo:master
from
odoo-dev:master-order-read_group-selection-adt
Conversation
This file contains 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
Elkasitu
commented
Sep 1, 2021
Elkasitu
force-pushed
the
master-order-read_group-selection-adt
branch
from
September 1, 2021 14:24
cf94bc8
to
a1bbaad
Compare
rco-odoo
reviewed
Sep 1, 2021
Elkasitu
force-pushed
the
master-order-read_group-selection-adt
branch
2 times, most recently
from
September 2, 2021 09:57
cb3e638
to
4ccf874
Compare
Elkasitu
force-pushed
the
master-order-read_group-selection-adt
branch
from
September 2, 2021 14:37
4ccf874
to
45496cb
Compare
Elkasitu
force-pushed
the
master-order-read_group-selection-adt
branch
from
September 3, 2021 08:34
45496cb
to
ea0cf7f
Compare
rco-odoo
force-pushed
the
master-order-read_group-selection-adt
branch
from
September 6, 2021 07:36
ea0cf7f
to
0420953
Compare
Before this commit, calling read_group on a model and grouping by a selection field would return the groups in alphabetical order, meaning that if your selection field's options were declared as: ('z', 'Z'), ('a', 'A') read_group would return first group 'a' and then group 'z', instead of groups 'z' and then 'a' which some might expect. With this commit, it is now possible to set a fields.Selection group_expand attribute to `True` when declaring it, which will use a default group_expand implementation specific to Selection fields, this means that when grouping by a Selection field with `group_expand=True` it will always return the groups in the definition order of the selection options. We achieve this by leveraging the group_expand field attribute which was designed for changing the groups returned by read_group. Since this attribute was thought only to be implemented on a Model-by-Model basis and here we need to use it as a generic function for all Selection fields (explicit group_expand declarations have higher precedence), the generic method has been implemented inside fields.Selection and takes an extra records parameter which holds a reference to the recordset/model on which read_group was called. This extra parameter only applies to field implementations of group_expand and in this case is what allows this specific feature to work with dynamic Selection fields (function as options). A side-effect of this implementation is that a read_group call that groups by a Selection field with `group_expand=True` that uses the default group_expand will always return all possible groups, even empty ones. Task-ID 2635052
rco-odoo
force-pushed
the
master-order-read_group-selection-adt
branch
from
September 6, 2021 07:40
0420953
to
637ef29
Compare
rco-odoo
approved these changes
Sep 6, 2021
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.
@robodoo r+
robodoo
pushed a commit
that referenced
this pull request
Sep 6, 2021
Before this commit, calling read_group on a model and grouping by a selection field would return the groups in alphabetical order, meaning that if your selection field's options were declared as: ('z', 'Z'), ('a', 'A') read_group would return first group 'a' and then group 'z', instead of groups 'z' and then 'a' which some might expect. With this commit, it is now possible to set a fields.Selection group_expand attribute to `True` when declaring it, which will use a default group_expand implementation specific to Selection fields, this means that when grouping by a Selection field with `group_expand=True` it will always return the groups in the definition order of the selection options. We achieve this by leveraging the group_expand field attribute which was designed for changing the groups returned by read_group. Since this attribute was thought only to be implemented on a Model-by-Model basis and here we need to use it as a generic function for all Selection fields (explicit group_expand declarations have higher precedence), the generic method has been implemented inside fields.Selection and takes an extra records parameter which holds a reference to the recordset/model on which read_group was called. This extra parameter only applies to field implementations of group_expand and in this case is what allows this specific feature to work with dynamic Selection fields (function as options). A side-effect of this implementation is that a read_group call that groups by a Selection field with `group_expand=True` that uses the default group_expand will always return all possible groups, even empty ones. Task-ID 2635052 closes #75856 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Elkasitu
pushed a commit
to odoo-dev/odoo
that referenced
this pull request
Sep 15, 2021
PR odoo#75856 introduced a default implementation of group_expand for Selection fields that set the value of group_expand to True. However the PR lacked the necessary bits that allow the same behavior for fields created on the fly instead of through code. This commit allows the propagation of the group_expand attribute for fields of type Selection, this commit also exposes the checkbox in the UI to enable/disable the setting.
robodoo
pushed a commit
that referenced
this pull request
Sep 17, 2021
PR #75856 introduced a default implementation of group_expand for Selection fields that set the value of group_expand to True. However the PR lacked the necessary bits that allow the same behavior for fields created on the fly instead of through code. This commit allows the propagation of the group_expand attribute for fields of type Selection, this commit also exposes the checkbox in the UI to enable/disable the setting. closes #76592 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
fw-bot
pushed a commit
to odoo-dev/odoo
that referenced
this pull request
Sep 17, 2021
PR odoo#75856 introduced a default implementation of group_expand for Selection fields that set the value of group_expand to True. However the PR lacked the necessary bits that allow the same behavior for fields created on the fly instead of through code. This commit allows the propagation of the group_expand attribute for fields of type Selection, this commit also exposes the checkbox in the UI to enable/disable the setting. X-original-commit: 1cacc3e
robodoo
pushed a commit
that referenced
this pull request
Sep 18, 2021
PR #75856 introduced a default implementation of group_expand for Selection fields that set the value of group_expand to True. However the PR lacked the necessary bits that allow the same behavior for fields created on the fly instead of through code. This commit allows the propagation of the group_expand attribute for fields of type Selection, this commit also exposes the checkbox in the UI to enable/disable the setting. closes #76775 X-original-commit: 1cacc3e Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
robodoo
pushed a commit
that referenced
this pull request
Sep 18, 2021
PR #75856 introduced a default implementation of group_expand for Selection fields that set the value of group_expand to True. However the PR lacked the necessary bits that allow the same behavior for fields created on the fly instead of through code. This commit allows the propagation of the group_expand attribute for fields of type Selection, this commit also exposes the checkbox in the UI to enable/disable the setting. closes #76775 X-original-commit: 1cacc3e Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this commit, calling read_group on a model and grouping by a
selection field would return the groups in alphabetical order, meaning
that if your selection field's options were declared as:
('z', 'Z'), ('a', 'A')
read_group would return first group 'a' and then group 'z', instead of
groups 'z' and then 'a' which some might expect.
With this commit, it is now possible to set a fields.Selection
group_expand attribute to
True
when declaring it, which will use adefault group_expand implementation specific to Selection fields, this
means that when grouping by a Selection field with
group_expand=True
it will always return the groups in the definition order of the
selection options.
We achieve this by leveraging the group_expand field attribute which was
designed for changing the groups returned by read_group.
Since this attribute was thought only to be implemented on a
Model-by-Model basis and here we need to use it as a generic function
for all Selection fields (explicit group_expand declarations have higher
precedence), the generic method has been implemented inside
fields.Selection and takes an extra records parameter which holds a
reference to the recordset/model on which read_group was called. This
extra parameter only applies to field implementations of group_expand
and in this case is what allows this specific feature to work with
dynamic Selection fields (function as options).
A side-effect of this implementation is that a read_group call that
groups by a Selection field with
group_expand=True
that uses thedefault group_expand will always return all possible groups, even
empty ones.
Task-ID
2635052