[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:
sbbaro
2019-02-27 15:52:43 +00:00
committed by Arnold Moyaux
parent 7c045dda0a
commit 2541db92f0
+3 -4
View File
@@ -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: