[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) <yosa@odoo.com>
Signed-off-by: John Laterre (jol) <jol@odoo.com>
This commit is contained in:
Yolann Sabaux
2023-02-23 14:54:44 +01:00
parent 987b82e5c9
commit d9151d6086
2 changed files with 17 additions and 1 deletions
@@ -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
@@ -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'}))