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] stock: set product_category_name as non-stored #162085

Closed
wants to merge 1 commit into from

Conversation

Aurelienvd
Copy link
Contributor

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 stored=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 the categ_id.parent_id.

opw-3861530


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 16, 2024

@C3POdoo C3POdoo requested a review from a team April 16, 2024 14:16
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Apr 16, 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
@clesgow
Copy link
Contributor

clesgow commented Apr 19, 2024

Thanks!
@robodoo r+

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>
@robodoo robodoo closed this Apr 19, 2024
@robodoo robodoo added the 17.3 label Apr 19, 2024
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
Labels
17.3 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

4 participants