From d9151d6086ccfc5a0bbcc7f9cefdc611f0310805 Mon Sep 17 00:00:00 2001 From: Yolann Sabaux Date: Wed, 15 Feb 2023 17:16:19 +0000 Subject: [PATCH] [FIX] account_check_printing: extend limit for check numbering Steps to reproduce: - Create a new journal Bank - In Sequence, find the 'New Bank Check" and edit it so the sequence can be 10 number digits long - Create a Vendor Payments with the the New Banck and Check as a method - Click on Print a check - Set any number > 2147483647 and validate Issue: Traceback Cause: The query SQL make a check to verifiy that the number is correct ('025'::integer == '25'::integer but '025'!='25) But using INTEGER limits the number up to 2147483647 (https://www.postgresql.org/docs/current/datatype-numeric.html) Solution: Use BIGINT whose limit is 9223372036854775807 opw-3140973 closes odoo/odoo#113499 X-original-commit: 49dd9dffd7b96fd90860123f8b3f0e623979b246 Signed-off-by: Yolann Sabaux (yosa) Signed-off-by: John Laterre (jol) --- .../models/account_payment.py | 2 +- .../tests/test_print_check.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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'}))