odoo/odoo#162085

Created by Aurélien van Delft (avd)
label
odoo-dev:master-opw-3861530-avd
head
2acbb9c57a31f37fef869421af0c013e9580d1d3
target
master
merged
1 month ago by Logistics, Quentin Wolfs (quwo)

[FIX] stock: set product_category_name as non-stored

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 odoo/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

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