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: product.stock_move_ids triggers performance problems when used on api.depends #91252

Open
wants to merge 1 commit into
base: 15.0
Choose a base branch
from

Conversation

hugho-ad
Copy link
Contributor

@hugho-ad hugho-ad commented May 12, 2022

api.depends should not be used on computed fields that are not stored = True
In order to avoid forcing it computation when aren't consulted

Consider the following scenario:

  • Configure MTO products
  • Sell the product
  • Confirmation will trigger the creation of MO and its stock.moves and will confirm them.

This is an exponential issue since we will see the performance issue
once we got at least 50K records on stock.move for each product that
it's a component on BOM.

Every time we wrote in a move, (by processing the MO of that product or
processing the moves of the pickings of that product) the api.depends on
_compute_quantities method, forces it to calculate the available quantity
when it is not really necessary because the fields that uses that
computed method are store=False and they aren't be consulted.

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

OPW 2852585

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

@robodoo
Copy link
Contributor

robodoo commented May 12, 2022

@C3POdoo C3POdoo requested a review from a team May 12, 2022 15:56
@C3POdoo C3POdoo added the Logistics about stock, mrp, delivery, purchase label May 12, 2022
@MiquelRForgeFlow
Copy link
Contributor

and what about adding @api.depends('type')?

@hugho-ad
Copy link
Contributor Author

@MiquelRForgeFlow
api.depends should not be used on computed fields that are not stored = True
In order to avoid forcing it computation when aren't consulted

@MiquelRForgeFlow
Copy link
Contributor

But if those non-stored fields appear in the form view, then you may want that they get updated. Without the api.depends, the value will not be updated in the form view. Right?

@nhomar
Copy link
Collaborator

nhomar commented May 17, 2022

@MiquelRForgeFlow they will, but just when you ask for them.

…n used on api.depends

 api.depends should not be used on computed fields that are not stored = True
In order to avoid forcing it computation when aren't consulted

Consider the following scenario:

- Configure MTO products
- Sell the product
- Confirmation will trigger the creation of MO and its stock.moves and will confirm them.

This is an exponential issue since we will see the performance issue
once we got at least 50K records on stock.move for each product that
it's a component on BOM.

Every time we wrote in a move, (by processing the MO of that product or
processing the moves of the pickings of that product) the api.depends on
_compute_quantities method, forces it to calculate the available quantity
when it is not really necessary because the fields that uses that
computed method are store=False and they aren't  be consulted.
@nhomar
Copy link
Collaborator

nhomar commented Jun 27, 2022

ping @odony

@Whenrow
Copy link
Contributor

Whenrow commented Jul 6, 2022

@hugho-ad Hello. The computed fields should not be recomputed in the same transaction unless the value is read as you mention. Are you sure you are not triggering the compute by the next MO (or picking) read that follow the validation to refresh the view ? This may be due to the availabilty widget on stock moves list view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Logistics about stock, mrp, delivery, purchase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants