diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 1f5e8c1b711..c7558c78b5b 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -4254,17 +4254,16 @@ class AccountMove(models.Model): ] limit = job_count + 1 - to_process = self.env['account.move']._read_group( + to_process = self.env['account.move'].search( [('send_and_print_values', '!=', False)], - groupby=['company_id'], - aggregates=['id:recordset'], limit=limit, ) need_retrigger = len(to_process) > job_count if not to_process: return - for _company, moves in to_process[:job_count]: + all_moves = to_process[:job_count] + for _company, moves in all_moves.grouped('company_id').items(): try: # Lock moves with self.env.cr.savepoint(flush=False): diff --git a/addons/account/tests/test_account_move_send.py b/addons/account/tests/test_account_move_send.py index 7593d95030b..d8bc94c04f3 100644 --- a/addons/account/tests/test_account_move_send.py +++ b/addons/account/tests/test_account_move_send.py @@ -1039,16 +1039,18 @@ class TestAccountMoveSend(TestAccountMoveSendCommon): order='id desc', limit=1, ) - self.assertEqual(json.loads(bus_1.message)['payload']['type'], 'success') - self.assertEqual(json.loads(bus_1.message)['payload']['action_button']['res_ids'], invoices_success.ids) + payload_1 = json.loads(bus_1.message)['payload'] + self.assertEqual(payload_1['type'], 'success') + self.assertEqual(sorted(payload_1['action_button']['res_ids']), invoices_success.ids) bus_2 = self.env['bus.bus'].sudo().search( [('channel', 'like', f'"res.partner",{sp_partner_2.id}')], order='id desc', limit=1, ) - self.assertEqual(json.loads(bus_2.message)['payload']['type'], 'warning') - self.assertEqual(json.loads(bus_2.message)['payload']['action_button']['res_ids'], invoices_error.ids) + payload_2 = json.loads(bus_2.message)['payload'] + self.assertEqual(payload_2['type'], 'warning') + self.assertEqual(sorted(payload_2['action_button']['res_ids']), invoices_error.ids) def test_send_and_print_only(self): invoice = self.init_invoice("out_invoice", amounts=[1000], post=True)