From 612f453a7424c582ba0f581b241d9a41f8908e2c Mon Sep 17 00:00:00 2001 From: alt-odoo <alt@odoo.com> Date: Tue, 23 Feb 2021 21:37:22 +0000 Subject: [PATCH] [FIX] account: wrong sequence number reset for refund type moves In case a yearly sequence is set for out_invoice/in_invoice types and if we set a monthly sequence on the corresponding out_refund/in_refund type, we will not be able to validate the refund the next month as it will be wrongly identified as a yearly sequence. We should include the move type when retrieving the last sequence name instead. --- addons/account/models/account_move.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 712817260d3c..71df912b68f7 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1154,6 +1154,9 @@ class AccountMove(models.Model): if not relaxed: domain = [('journal_id', '=', self.journal_id.id), ('id', '!=', self.id or self._origin.id), ('name', 'not in', ('/', False))] + if self.journal_id.refund_sequence: + refund_types = ('out_refund', 'in_refund') + domain += [('move_type', 'in' if self.move_type in refund_types else 'not in', refund_types)] reference_move_name = self.search(domain + [('date', '<=', self.date)], order='date desc', limit=1).name if not reference_move_name: reference_move_name = self.search(domain, order='date asc', limit=1).name -- GitLab