OCA / account-analytic

Odoo Account Analytic Related Addons
GNU Affero General Public License v3.0
103 stars 361 forks source link

[IMP] stock_picking_analytic: improve the performance of the analytic distribution computation #660

Closed CLaurelB closed 4 months ago

CLaurelB commented 4 months ago

Replaced the stock picking analytic distribution search and validations with a query to improve performance when there are large amounts of picking and move records. Also, updated test to handle a case where there are different analytic accounts on moves related to a picking.

CLaurelB commented 4 months ago

@luisg123v could you review, please?

moylop260 commented 4 months ago

Do you have stats about before/after this fix?

Is needed to use apply_rules and active=True filter? e.g. https://github.com/odoo/odoo/pull/165010/files

moylop260 commented 4 months ago

In general LGTM since that you only need one record from the whole recordset

so psql is better to manage this

CLaurelB commented 4 months ago

Hi @moylop260

Do you have stats about before/after this fix?

We do not have stats because before the change, the field computation for all records did not even finish and the process would die.

Is needed to use apply_rules and active=True filter? e.g. https://github.com/odoo/odoo/pull/165010/files

Stored computed fields are already calculated as sudo, so rules and permissions do not apply. None of these models have an active field, so the active test also does not apply.

moylop260 commented 4 months ago

/ocabot merge patch

OCA-git-bot commented 4 months ago

What a great day to merge this nice PR. Let's do it! Prepared branch 16.0-ocabot-merge-pr-660-by-moylop260-bump-patch, awaiting test results.

OCA-git-bot commented 4 months ago

Congratulations, your PR was merged at 322249a5c21e35f16627fc33a847cfa9a36494f4. Thanks a lot for contributing to OCA. ❤️