[FIX] purchase: ameliorate the performance of _create_stock_moves
When confirming purchase orders with a lot of lines the performance is very slow (sometimes reaches the memory limit). Creating the stock moves in only a multiple create ameliorates the performance. opw 1929276 closes odoo/odoo#31471
This commit is contained in:
@@ -347,12 +347,11 @@ class PurchaseOrderLine(models.Model):
|
||||
|
||||
@api.multi
|
||||
def _create_stock_moves(self, picking):
|
||||
moves = self.env['stock.move']
|
||||
done = self.env['stock.move'].browse()
|
||||
values = []
|
||||
for line in self:
|
||||
for val in line._prepare_stock_moves(picking):
|
||||
done += moves.create(val)
|
||||
return done
|
||||
values.append(val)
|
||||
return self.env['stock.move'].create(values)
|
||||
|
||||
def _update_received_qty(self):
|
||||
for line in self:
|
||||
|
||||
Reference in New Issue
Block a user