From 0f548c3047a129d771d6890e92bb94a748138a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20=28avd=29?= Date: Thu, 16 Sep 2021 13:27:17 +0000 Subject: [PATCH] [IMP] stock: avoid calling quant_tasks by default. Currently, a cron is called once a day (by default) to merge duplicated quants. Moreover, each time the customer loads the Inventory Report, the duplicated quants are also merged. This is a bit overkill as duplicated quants due to concurrent updates are quite rare. Also, merging quants can be quite slow when the stock.quant table is big (>1M). This commit adds an ir.config_parameter to turn off the merging of quants when accessing the Inventory Report. It can be switched back on for a specific DB if duplicated quants happen more frequently. opw-2574152 closes odoo/odoo#87119 X-original-commit: bb2cb76a724c1bc12aa7e515b1376b88ffd97b3d Signed-off-by: Arnold Moyaux --- addons/stock/models/stock_quant.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 2b01d0139c9..cfd1b6150e3 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -917,7 +917,8 @@ class StockQuant(models.Model): :param domain: List for the domain, empty by default. :param extend: If True, enables form, graph and pivot views. False by default. """ - self._quant_tasks() + if not self.env['ir.config_parameter'].sudo().get_param('stock.skip_quant_tasks'): + self._quant_tasks() ctx = dict(self.env.context or {}) ctx['inventory_report_mode'] = True ctx.pop('group_by', None)