From 7aef86fa69501d5e2192e81f7d717cd28bc27f87 Mon Sep 17 00:00:00 2001 From: Roopam Rathod Date: Thu, 18 Feb 2021 13:16:54 +0000 Subject: [PATCH] [FIX] account:Auto Post scheduler action threads killed by timeout. Before this commit: When there is too much records to post and it's take time more than 15 minutes then server was restarted. So scheduler action will do the process with the same records again and again. After this commit: post record in batch of 1000 opw-2451446 closes odoo/odoo#70831 X-original-commit: 819321c3a129613890ce49e3efe9a903c3218070 Signed-off-by: rrt-odoo --- addons/account/models/account_move.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 96e5f4213b1..a1afee941c4 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2959,7 +2959,10 @@ class AccountMove(models.Model): ('date', '<=', fields.Date.context_today(self)), ('auto_post', '=', True), ]) - records._post() + for ids in self._cr.split_for_in_conditions(records.ids, size=1000): + self.browse(ids)._post() + if not self.env.registry.in_test_mode(): + self._cr.commit() # offer the possibility to duplicate thanks to a button instead of a hidden menu, which is more visible def action_duplicate(self):