From e55edef6ae4aecd117e3ab6f91a8e3bc3f8a561e Mon Sep 17 00:00:00 2001 From: Yolann Sabaux Date: Mon, 6 Mar 2023 08:27:21 +0000 Subject: [PATCH] [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) Signed-off-by: Yolann Sabaux (yosa) --- .../account_check_printing/models/account_payment.py | 2 +- .../account_check_printing/tests/test_print_check.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/account_check_printing/models/account_payment.py b/addons/account_check_printing/models/account_payment.py index 84444dc3fca..6d5625e64e3 100644 --- a/addons/account_check_printing/models/account_payment.py +++ b/addons/account_check_printing/models/account_payment.py @@ -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, diff --git a/addons/account_check_printing/tests/test_print_check.py b/addons/account_check_printing/tests/test_print_check.py index b62f184dfc0..fa100ffc7a0 100644 --- a/addons/account_check_printing/tests/test_print_check.py +++ b/addons/account_check_printing/tests/test_print_check.py @@ -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.")