Skip to content
Snippets Groups Projects
Commit 36652653 authored by Yolann Sabaux's avatar Yolann Sabaux
Browse files

[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#112832

Signed-off-by: default avatarJohn Laterre (jol) <jol@odoo.com>
parent 3e58af4b
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,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
......
......@@ -161,3 +161,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_id': self.payment_method_check.id,
})
payment.action_post()
self.assertTrue(payment.write({'check_number': '2147483647'}))
self.assertTrue(payment.write({'check_number': '2147483648'}))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment