From 77e935f02b0dedfdcb75263d0dba9c00c25cbd7a Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 10 Dec 2020 14:09:02 +0000 Subject: [PATCH] [FIX] account_check_printing: Check number in Payment Steps to reproduce the bug: - Let's consider a bank journal BJ with manual numbering activated - Create a customer payment CP using BJ as journal and confirm CP - Create a vendor payment VP using BJ as journal, select Check as payment method - A Check Number with 0001 is automatically assigned to VP - Confirm or save VP Bug: An error was raised saying that: The following numbers are already used: 0001 PS: When creating the customer payment, a check number was assigned to CP even if customer payment has nothing to do with check numbers opw:2415170 closes odoo/odoo#63372 X-original-commit: f01eb942716800921148b5de8d6bc4140d122912 Signed-off-by: Laurent Smet Signed-off-by: Simon Goffin (sig) --- addons/account_check_printing/models/account_payment.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account_check_printing/models/account_payment.py b/addons/account_check_printing/models/account_payment.py index 12a75b14980..863623576e2 100644 --- a/addons/account_check_printing/models/account_payment.py +++ b/addons/account_check_printing/models/account_payment.py @@ -21,6 +21,7 @@ class AccountPayment(models.Model): string="Check Number", store=True, readonly=True, + copy=False, compute='_compute_check_number', inverse='_inverse_check_number', help="The selected journal is configured to print check numbers. If your pre-printed check paper already has numbers " @@ -48,6 +49,8 @@ class AccountPayment(models.Model): AND move.journal_id = other_move.journal_id AND payment.id != other_payment.id AND payment.id IN %(ids)s + AND move.state = 'posted' + AND other_move.state = 'posted' """, { 'ids': tuple(self.ids), }) @@ -70,10 +73,10 @@ class AccountPayment(models.Model): else: pay.check_amount_in_words = False - @api.depends('journal_id') + @api.depends('journal_id', 'payment_method_code') def _compute_check_number(self): for pay in self: - if pay.journal_id.check_manual_sequencing: + if pay.journal_id.check_manual_sequencing and pay.payment_method_code == 'check_printing': sequence = pay.journal_id.check_sequence_id pay.check_number = sequence.get_next_char(sequence.number_next_actual) else: