[FIX] stock: avoid flush all env in quants update
Issue: The `_update_available_quantity` will flush the all environment due to the savepoint (at each call). When we working with the package, it becomes bottleneck due to the `_compute_package_info`. Indeed, it computes two compute store field (`location_id` and `company_id`) and depends of multiple field of related quants `quants_ids.xxx`. It means that each time we enter/exit in the savepoint to update quants, this compute will be execute (because of flush + compute_store). Solution: Avoid flushing when enter in the savepoint of `_update_available_quantity` (`flush=False`) Performance gain: To validate a Delivery with 1000 move lines with package (source and dest): - Without patch: +- 120 sec - With patch: +- 17 sec opw-2371161 closes odoo/odoo#62841 X-original-commit: b2d57323caf9f7fe47c4fe9ac26b0e955d9987b9 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com> Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
This commit is contained in:
@@ -414,7 +414,7 @@ class StockQuant(models.Model):
|
||||
|
||||
for quant in quants:
|
||||
try:
|
||||
with self._cr.savepoint():
|
||||
with self._cr.savepoint(flush=False): # Avoid flush compute store of package
|
||||
self._cr.execute("SELECT 1 FROM stock_quant WHERE id = %s FOR UPDATE NOWAIT", [quant.id], log_exceptions=False)
|
||||
quant.write({
|
||||
'quantity': quant.quantity + quantity,
|
||||
|
||||
Reference in New Issue
Block a user