[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. X-original-commit: 612f453a7424c582ba0f581b241d9a41f8908e2c
This commit is contained in:
@@ -1161,6 +1161,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
|
||||
|
||||
Reference in New Issue
Block a user