[FIX] account_check_printing: enable increment in new payment

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 the check number to 2147483648 and validate
- Create a new payment with the check method
- Click on Print a check

Issue:
Error is raised

Cause:
As for https://github.com/odoo/odoo/pull/112832 there is a second check in order to increment the check number

opw-3140973

closes odoo/odoo#114496

X-original-commit: 531147bb5fad6372c3742bc061f78687f7f11e5b
Signed-off-by: John Laterre (jol) <jol@odoo.com>
Signed-off-by: Yolann Sabaux (yosa) <yosa@odoo.com>
This commit is contained in:
Yolann Sabaux
2023-03-07 02:56:57 +01:00
parent a4a0fb233b
commit e55edef6ae
2 changed files with 9 additions and 3 deletions
@@ -160,7 +160,7 @@ class AccountPayment(models.Model):
JOIN account_move move ON movE.id = payment.move_id
WHERE journal_id = %(journal_id)s
AND payment.check_number IS NOT NULL
ORDER BY payment.check_number::INTEGER DESC
ORDER BY payment.check_number::BIGINT DESC
LIMIT 1
""", {
'journal_id': self.journal_id.id,
@@ -180,13 +180,19 @@ class TestPrintCheck(AccountTestInvoicingCommon):
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({
vals = {
'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 = self.env['account.payment'].create(vals)
payment.action_post()
self.assertTrue(payment.write({'check_number': '2147483647'}))
self.assertTrue(payment.write({'check_number': '2147483648'}))
payment_2 = self.env['account.payment'].create(vals)
payment_2.action_post()
action_window = payment_2.print_checks()
self.assertEqual(action_window['context']['default_next_check_number'], '2147483649', "Check number should have been incremented without error.")