[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 <smetl@users.noreply.github.com>
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2020-12-15 10:06:19 +00:00
parent 6316dd76d4
commit 77e935f02b
@@ -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: