CRM, Sales & Marketing mailing list archives

crm-sales-marketing@odoo-community.org

Avatar

Re: Big performance issue with sale orders with more than 500 lines

by
Landoo SL, Josean Soroa
- 31/03/2022 12:26:10
Hi Quentin, thanks for your answer.

Your solution is good and helps reducing the number of calculation cycles but main problem continues.
With each "order_data.update", Odoo has to read each one of sale order lines to update the fields amount_untaxed, amount_tax and amount_total of sale.order.
And this is a problem with more than 500 lines. In our case our customer has more than 1000 lines and updating sale order takes more than 5 minutes.

I think we can't solve that, without changing "_amount_all()" method.
The only idea we have is to use actual value of amount_untaxed, amount_tax and amount_total and add amount of new lines. 
But it can be risky. Anyone has tried this or other solution with good result?

Thanks.
-----------------------------------------------------------
Josean Soroa
-----------------------------------------------------------

by "Quentin THEURET" <contact@kerpeo.com> -  22/03/2022 12:24:26
HI,
You can test to create the lines at the same time as the sale order by using this (my example contains only 2 line, but you do it with multiple lines) :
order_data = YOUR_ORDER_DATA_DICT
line1_data = LINE1_DATA_DICT
line2_date = LINE2_DATA_DICT
order_data.update({'order_line': [(0, 0, line1_data), (0, 0, line2_data)]})
sale = self.env['sale.order'].create(order_data)
I hope my explanation will help you.
Have a good day


Reference