Skip to content
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

[FIX] web: handle field sorting should include id #162933

Closed
wants to merge 1 commit into from

Conversation

kebeclibre
Copy link
Contributor

Since commit 7d2baaa ("Unity read"), we are able to pass a full specification to subfields in a view and retrive records directly according to that specification. This could include "order".

In the case of a list view that has a widget="handle", this order is automatically set to "[handle_field] ASC".

Before the unity read feature, it did not cause problems for one2manys because the ids of records were retrieved in python using the "natural order" of the model (the model._order slot), which usually had the right parameters. (see sale.order.line for example). When fetching the ids of the one2many, those were already sorted in natural order.

In unity read, the natural order is overriden by the specification and became only "[handle_field] ASC". This was insufficient as more often than not, sequences on model are set up with a default. So eventually, all records couls have the same sequence. The sorting in SQL becomes undeterminate.

After this commit, we had the sorting key "id ASC" to avoid any unwanted results.

opw-3790378

see discord https://discord.com/channels/678381219515465750/687338039717920792/1231977078564585555 for a detailed discussion.

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Apr 23, 2024

Pull request status dashboard.

Copy link
Contributor

@aab-odoo aab-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kebeclibre

robodoo r+

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Apr 23, 2024
Since commit 7d2baaa ("Unity read"), we are able to
pass a full specification to subfields in a view and retrive records directly according to that
specification. This could include "order".

In the case of a list view that has a `widget="handle"`, this order is automatically set to "[handle_field] ASC".

Before the unity read feature, it did not cause problems for one2manys because the ids of records were retrieved in python
using the  "natural order" of the model (the `model._order` slot), which usually had the right parameters.
(see `sale.order.line` for example). When fetching the ids of the one2many, those were already sorted in natural order.

In unity read, the natural order is overriden by the specification and became only "[handle_field] ASC". This was insufficient
as more often than not, sequences on model are set up with a default. So eventually, all records couls have the same sequence.
The sorting in SQL becomes undeterminate.

After this commit, we had the sorting key "id ASC" to avoid any unwanted results.

opw-3790378

see discord https://discord.com/channels/678381219515465750/687338039717920792/1231977078564585555 for a detailed discussion.
@kebeclibre kebeclibre force-pushed the 17.0-handle-field-sort-id-lpe branch from 3a3ec94 to ecc0a38 Compare April 23, 2024 09:16
@kebeclibre
Copy link
Contributor Author

robodoo r+

@fw-bot
Copy link
Contributor

fw-bot commented Apr 27, 2024

2 similar comments
@fw-bot
Copy link
Contributor

fw-bot commented Apr 28, 2024

@fw-bot
Copy link
Contributor

fw-bot commented Apr 29, 2024

willylohws pushed a commit to willylohws/odoo that referenced this pull request May 1, 2024
Since commit 7d2baaa ("Unity read"), we are able to
pass a full specification to subfields in a view and retrive records directly according to that
specification. This could include "order".

In the case of a list view that has a `widget="handle"`, this order is automatically set to "[handle_field] ASC".

Before the unity read feature, it did not cause problems for one2manys because the ids of records were retrieved in python
using the  "natural order" of the model (the `model._order` slot), which usually had the right parameters.
(see `sale.order.line` for example). When fetching the ids of the one2many, those were already sorted in natural order.

In unity read, the natural order is overriden by the specification and became only "[handle_field] ASC". This was insufficient
as more often than not, sequences on model are set up with a default. So eventually, all records couls have the same sequence.
The sorting in SQL becomes undeterminate.

After this commit, we had the sorting key "id ASC" to avoid any unwanted results.

opw-3790378

see discord https://discord.com/channels/678381219515465750/687338039717920792/1231977078564585555 for a detailed discussion.

closes odoo#162933

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
@fw-bot fw-bot deleted the 17.0-handle-field-sort-id-lpe branch May 7, 2024 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants