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] stock: set product_category_name as non-stored #162085
Closed
Closed
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
Currently stock_move_line.product_category_name is a stored related field relating to product_id.categ_id.complete_name. Because product.category.complete_name is itself a computed-stored field that depends on parent_id.complete_name, changing the parent_id of a given product_category categ_id triggers the recomputation of categ_id.complete_name which triggers the recomputation of stock_move_line.product_category_name. In the case where there are lots of stock_move_lines for the same product_category this can lead to slowdowns or even MemoryErrors when the recomputation happens for 1M smls. This commit set product_category_name as non-stored. The only reason why it was stored in the first place was to allow users to group by category name from the webui (in Kanban, List and Pivot). It's not required to store related fields for that since odoo#127353 (except if they are explicitly mark as compute_sudo=False, which is not the case here). This removes the need to retrigger the computation of stock_move_line.product_category_name when changing the categ_id.parent_id. opw-3861530
Aurelienvd
force-pushed
the
master-opw-3861530-avd
branch
from
April 17, 2024 09:03
7ee5936
to
2acbb9c
Compare
Thanks! |
robodoo
pushed a commit
that referenced
this pull request
Apr 19, 2024
Currently stock_move_line.product_category_name is a stored related field relating to product_id.categ_id.complete_name. Because product.category.complete_name is itself a computed-stored field that depends on parent_id.complete_name, changing the parent_id of a given product_category categ_id triggers the recomputation of categ_id.complete_name which triggers the recomputation of stock_move_line.product_category_name. In the case where there are lots of stock_move_lines for the same product_category this can lead to slowdowns or even MemoryErrors when the recomputation happens for 1M smls. This commit set product_category_name as non-stored. The only reason why it was stored in the first place was to allow users to group by category name from the webui (in Kanban, List and Pivot). It's not required to store related fields for that since #127353 (except if they are explicitly mark as compute_sudo=False, which is not the case here). This removes the need to retrigger the computation of stock_move_line.product_category_name when changing the categ_id.parent_id. opw-3861530 closes #162085 Related: odoo/upgrade#5928 Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
zel-odoo
pushed a commit
to odoo-dev/odoo
that referenced
this pull request
Apr 29, 2024
Currently stock_move_line.product_category_name is a stored related field relating to product_id.categ_id.complete_name. Because product.category.complete_name is itself a computed-stored field that depends on parent_id.complete_name, changing the parent_id of a given product_category categ_id triggers the recomputation of categ_id.complete_name which triggers the recomputation of stock_move_line.product_category_name. In the case where there are lots of stock_move_lines for the same product_category this can lead to slowdowns or even MemoryErrors when the recomputation happens for 1M smls. This commit set product_category_name as non-stored. The only reason why it was stored in the first place was to allow users to group by category name from the webui (in Kanban, List and Pivot). It's not required to store related fields for that since odoo#127353 (except if they are explicitly mark as compute_sudo=False, which is not the case here). This removes the need to retrigger the computation of stock_move_line.product_category_name when changing the categ_id.parent_id. opw-3861530 closes odoo#162085 Related: odoo/upgrade#5928 Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.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.
Currently
stock_move_line.product_category_name
is a stored related field relating toproduct_id.categ_id.complete_name
. Becauseproduct.category.complete_name
is itself a computed-stored field that depends onparent_id.complete_name
, changing the parent_id of a given product_categorycateg_id
triggers the recomputation ofcateg_id.complete_name
which triggers the recomputation ofstock_move_line.product_category_name
. In the case where there are lots of stock_move_lines for the same product_category this can lead to slowdowns or even MemoryErrors when the recomputation happens for 1M smls.This commit set
product_category_name
asstored=False
. The only reason why it was stored in the first place was to allow users to group by category name from the webui (in Kanban, List and Pivot). It's not required to store related fields for that since #127353 (except if they are explicitly mark as compute_sudo=False, which is not the case here).This removes the need to retrigger the computation of
stock_move_line.product_category_name
when changing thecateg_id.parent_id
.opw-3861530
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr