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

[IMP] sale_margin_percentage: optimize migration script T#78545 #1674

Merged

Conversation

luisg123v
Copy link
Contributor

@luisg123v luisg123v commented Jul 7, 2024

There's a migration script to recompute sales marging on sale order lines, which was raising memory errors with databases that contain many lines.

The following optimizations are applied:

  • Don't call compute method directly but mark the field to be computed. This avoids one write per record and makes the ORM to take care of batches.
  • Read currency directly from the line, instead of from the pricelist which in turn requires reading the order.
  • Don't read currency if quantity is zero as it won't be used anyway

@luisg123v luisg123v force-pushed the 15.0-sale_margin_mig_optimization-luisg branch from 83f771e to 9fb5d86 Compare July 7, 2024 15:31
@CLaurelB
Copy link
Contributor

CLaurelB commented Jul 7, 2024

LGTM 👍

There's a migration script to recompute sales marging on sale order
lines, which was raising memory errors with databases that contain many
lines.

The following optimizations are applied:
- Don't call compute method directly but mark the field to be computed.
  This avoids one write per record and makes the ORM to take care of
  batches.
- Read currency directly from the line, instead of from the pricelist
  which in turn requires reading the order.
- Don't read currency if quantity is zero as it won't be used anyway
@luisg123v luisg123v force-pushed the 15.0-sale_margin_mig_optimization-luisg branch from 9fb5d86 to 34fc9e8 Compare July 11, 2024 01:56
@luisg123v luisg123v merged commit 34fc9e8 into Vauxoo:15.0 Jul 11, 2024
2 of 3 checks passed
@luisg123v luisg123v deleted the 15.0-sale_margin_mig_optimization-luisg branch July 11, 2024 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants