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] account, sale: create invoice lines in batch #31975

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
5 participants
@Elkasitu
Copy link
Contributor

Elkasitu commented Mar 20, 2019

This patch changes the create of account.invoice.line to use
model_create_multi, which allows the batch creation of multiple
invoice lines while only triggering the recompute of all related fields
once.

It also changes the generation of invoices from a SO to take advantage
of the create multi of account.invoice.line.

For a SO of 2000 lines:
Pre-patch:
~417s to generate an Invoice
Post-patch:
~30s to generate an Invoice

  • Check if writes can be performed in batch
  • Create similar patch for versions < 12 (no create multi)
  • Attach flamegraphs

NOTE: To be merged with rebase-ff if second patch is mergeable, the second patch reduces the time further from ~30s to ~19s

FlameGraphs:
InvoiceGeneration.zip

@robodoo robodoo added the seen 🙂 label Mar 20, 2019

@C3POdoo C3POdoo added the RD label Mar 20, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 20, 2019

@Elkasitu Elkasitu requested review from qdp-odoo, nim-odoo and rco-odoo Mar 20, 2019

@Elkasitu Elkasitu marked this pull request as ready for review Mar 20, 2019

@robodoo robodoo added the CI 🤖 label Mar 20, 2019

Show resolved Hide resolved addons/sale/models/sale.py
Show resolved Hide resolved addons/sale/models/sale.py Outdated

@Elkasitu Elkasitu force-pushed the odoo-dev:12.0-perf-so-invoice-gen-adt branch from 7a754d5 to f819104 Mar 20, 2019

@robodoo robodoo removed the CI 🤖 label Mar 20, 2019

@nim-odoo
Copy link
Contributor

nim-odoo left a comment

About the second patch, I think we should tackle the issue corrected by e6ff16c differently. The use case described in the commit is not very common, so I guess we could rewrite slightly the logic to avoid computing the taxes twice in most cases.

Show resolved Hide resolved addons/account/models/account_invoice.py
Show resolved Hide resolved addons/sale/models/sale.py
Show resolved Hide resolved addons/sale/models/sale.py Outdated

@robodoo robodoo added the CI 🤖 label Mar 20, 2019

[FIX] account, sale: create invoice lines in batch
This patch changes the create of `account.invoice.line` to use
`model_create_multi`, which allows the batch creation of multiple
invoice lines while only triggering the recompute of all related fields
once.

It also changes the generation of invoices from a SO to take advantage
of the create multi of `account.invoice.line`.

For a SO of 2000 lines:
    Pre-patch:
        ~417s to generate an Invoice
    Post-patch:
        ~30s to generate an Invoice

@Elkasitu Elkasitu force-pushed the odoo-dev:12.0-perf-so-invoice-gen-adt branch from f819104 to 5c04369 Mar 20, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 20, 2019

@Elkasitu Elkasitu force-pushed the odoo-dev:12.0-perf-so-invoice-gen-adt branch from 5c04369 to a881ab6 Mar 20, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 20, 2019

@Elkasitu Elkasitu requested review from rco-odoo and nim-odoo Mar 21, 2019

@Elkasitu Elkasitu removed the request for review from qdp-odoo Mar 21, 2019

@rco-odoo
Copy link
Member

rco-odoo left a comment

robodoo r+

@robodoo robodoo added the r+ 👌 label Mar 21, 2019

robodoo pushed a commit that referenced this pull request Mar 21, 2019

[FIX] account, sale: create invoice lines in batch
This patch changes the create of `account.invoice.line` to use
`model_create_multi`, which allows the batch creation of multiple
invoice lines while only triggering the recompute of all related fields
once.

It also changes the generation of invoices from a SO to take advantage
of the create multi of `account.invoice.line`.

For a SO of 2000 lines:
    Pre-patch:
        ~417s to generate an Invoice
    Post-patch:
        ~30s to generate an Invoice

closes #31975

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>

@robodoo robodoo closed this in f4b7dab Mar 21, 2019

@robodoo robodoo added merged 🎉 and removed merging 👷 labels Mar 21, 2019

@robodoo

This comment has been minimized.

Copy link
Contributor

robodoo commented Mar 21, 2019

Merged, thanks!

@nim-odoo nim-odoo deleted the odoo-dev:12.0-perf-so-invoice-gen-adt branch Mar 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.