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

[8.0] Too many calculations on price_subtotal field on sale.order.line #8537

Closed
hugosantosred opened this issue Sep 15, 2015 · 10 comments
Closed
Assignees

Comments

@hugosantosred
Copy link
Contributor

We are experiencing issues when saving big sale orders (~ 500 Lines) it always throws a CPU Time limit Exceeded error.

Debugging this I've noticed than price_subtotal field is recomputed too many times (Also I tested with a database with demo data and only sale module installed)

I've put a logger in _amount_line in sale.py and for a 2 line sale order is doing this:

2015-09-15 12:46:15,900 11808 WARNING test_big_so openerp.addons.sale.sale: AMOUNT LINE [15, 798]
2015-09-15 12:46:15,947 11808 WARNING test_big_so openerp.addons.sale.sale: AMOUNT LINE [15, 798]
2015-09-15 12:46:15,963 11808 WARNING test_big_so openerp.addons.sale.sale: AMOUNT LINE [15, 798]
2015-09-15 12:46:16,236 11808 WARNING test_big_so openerp.addons.sale.sale: AMOUNT LINE [15, 798]

So if the order has 500 lines, when saving it, will block the ERP in multiple workers mode or it will spend nearly a half hour on saving this sale order.

To reproduce this behaviour:

  • Create a new sale order
  • Add many lines to it and save the order (This time this error is not going to happen and the order will save as expected)
  • Change the fiscal position in the order, so it will update the taxes on all the lines
  • Save the order again. (Now it's going to spend a lot of time calculating amount_line in the order)

Anyone else has noticed this behaviour?

@pedrobaeza
Copy link
Collaborator

Taxes are not re-calculated when you change the fiscal position by default. You should have a module that does that. It's the same problem highlighted in this PR: OCA/sale-workflow#54 (comment), but I haven't found a solution to disable compute triggers temporarily

@rvalyi
Copy link
Contributor

rvalyi commented Sep 15, 2015

@hugosantosred yes on 6.1 already ;-) ...
So basically we had a module recomputing the taxes on fiscal position changes because it was not native by that time. The problem was each time something was changed at the line level, it would recompute stored fields at the order level. We avoided that by setting a special context key while writing to the line and disabled computed fields computation with an ORM patch when that key was found in the context. That is context key is now native in the ORM but I forgot its name. I guess the new API is having the same trouble under the hood when you change a fiscal position (not sure if it has been recently implemented) so may be it's worth investigating if the same kind of fix would work.

In any case you are right, that would be cool Odoo to be tested with large orders and not only 2 lines orders to avoid these issues. I m curious about your feedback if you manage to work around it.

@sebalix
Copy link
Contributor

sebalix commented Sep 18, 2015

I think the context key in v8 is recompute (self.env[MODEL].with_context(recompute=False), I didn't tested however.

@pedrobaeza
Copy link
Collaborator

I tried that on this PR OCA/sale-workflow#54 and didn't work. Maybe I missed something?

@sebalix
Copy link
Contributor

sebalix commented Sep 18, 2015

Well, it seems that it is only for new-style fields: https://github.com/odoo/odoo/blob/8.0/openerp/models.py#L4029, I have not found similar key for the old-API.

@liebana
Copy link

liebana commented Sep 21, 2015

Let's wait until @odony (hopefully) has time to check this out. The problem to fix this in v8 (I suppose) is that with the changes on sale order in v9 this issue is going to be deprecated.

@JakeStoeffler
Copy link

Does this also affect OpenERP v7? I have a client whose large sales orders (~300 lines) are taking upwards of five minutes to confirm (from quote to order). I had to increase limit_time_cpu and limit_time_real to get them to work at all -- otherwise it would always time out after a minute. This long load time is simply not acceptable for them. Does anyone have a solution?

@liebana
Copy link

liebana commented Oct 29, 2015

@JakeStoeffler The answer seems to be NO without developing some module to improve performance.

@mlaitinen
Copy link
Contributor

@JakeStoeffler Have you made any modifications to sale.order or sale.order.line code?

@Yenthe666
Copy link
Collaborator

Hi @hugosantosred ,

Thank you for your bug report and our apoligies that we haven't had the time to look at this bug report. We do our best to handle all of them, but we sometimes miss some.
At this point Odoo 8 is no longer supported as Odoo only supports three versions (9.0, 10.0, 11.0 at the moment).
If you can still reproduce this issue on Odoo 9, Odoo 10 or Odoo 11 we encourage you to create a new bug report.
P.S: A lot of performance problems have been countered or improved in Odoo 11.

Regards,
Yenthe

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

No branches or pull requests

9 participants