diff --git a/addons/account_check_printing/models/account_payment.py b/addons/account_check_printing/models/account_payment.py index d0ac8d449ca..84444dc3fca 100644 --- a/addons/account_check_printing/models/account_payment.py +++ b/addons/account_check_printing/models/account_payment.py @@ -69,7 +69,7 @@ class AccountPayment(models.Model): JOIN account_journal journal ON journal.id = move.journal_id, account_payment other_payment JOIN account_move other_move ON other_move.id = other_payment.move_id - WHERE payment.check_number::INTEGER = other_payment.check_number::INTEGER + WHERE payment.check_number::BIGINT = other_payment.check_number::BIGINT AND move.journal_id = other_move.journal_id AND payment.id != other_payment.id AND payment.id IN %(ids)s diff --git a/addons/account_check_printing/tests/test_print_check.py b/addons/account_check_printing/tests/test_print_check.py index 1d0423ac8a3..b62f184dfc0 100644 --- a/addons/account_check_printing/tests/test_print_check.py +++ b/addons/account_check_printing/tests/test_print_check.py @@ -174,3 +174,19 @@ class TestPrintCheck(AccountTestInvoicingCommon): })._create_payments() self.assertEqual(set(payments.mapped('check_number')), {str(x) for x in range(11111, 11111 + nb_invoices_to_test)}) + + def test_print_great_pre_number_check(self): + """ + Make sure we can use integer of more than 2147483647 in check sequence + limit of `integer` type in psql: https://www.postgresql.org/docs/current/datatype-numeric.html + """ + payment = self.env['account.payment'].create({ + 'payment_type': 'outbound', + 'partner_type': 'supplier', + 'amount': 100.0, + 'journal_id': self.company_data['default_journal_bank'].id, + 'payment_method_line_id': self.payment_method_line_check.id, + }) + payment.action_post() + self.assertTrue(payment.write({'check_number': '2147483647'})) + self.assertTrue(payment.write({'check_number': '2147483648'}))