diff --git a/addons/account/tests/test_sequence_mixin.py b/addons/account/tests/test_sequence_mixin.py index 2f642d91973..558946378e7 100644 --- a/addons/account/tests/test_sequence_mixin.py +++ b/addons/account/tests/test_sequence_mixin.py @@ -639,6 +639,26 @@ class TestSequenceMixin(TestSequenceMixinCommon): for move in payments.move_id: self.assertRecordValues(move.line_ids, [{'move_name': move.name}] * len(move.line_ids)) + def test_resequence_payment_and_non_payment_without_payment_sequence(self): + """Resequence wizard could be open for different move type if the payment sequence is set to False on the journal.""" + journal = self.company_data['default_journal_bank'].copy({'payment_sequence': False}) + bsl = self.env['account.bank.statement.line'].create({'name': 'test', 'amount': 100, 'journal_id': journal.id}) + payment = self.env['account.payment'].create({ + 'payment_type': 'inbound', + 'partner_id': self.partner_a.id, + 'amount': 100, + 'journal_id': journal.id, + }) + + payment.action_post() + wizard = Form(self.env['account.resequence.wizard'].with_context( + active_ids=(payment.move_id + bsl.move_id).ids, + active_model='account.move'), + ) + + wizard.save().resequence() + self.assertTrue(wizard) + @tagged('post_install', '-at_install') class TestSequenceMixinDeletion(TestSequenceMixinCommon): diff --git a/addons/account/wizard/account_resequence.py b/addons/account/wizard/account_resequence.py index 417cbd3dfe2..737ffc7f11c 100644 --- a/addons/account/wizard/account_resequence.py +++ b/addons/account/wizard/account_resequence.py @@ -40,7 +40,10 @@ class ReSequenceWizard(models.TransientModel): ): raise UserError(_('The sequences of this journal are different for Invoices and Refunds but you selected some of both types.')) is_payment = set(active_move_ids.mapped(lambda x: bool(x.payment_id))) - if len(is_payment) > 1: + if ( + active_move_ids.journal_id.payment_sequence + and len(is_payment) > 1 + ): raise UserError(_('The sequences of this journal are different for Payments and non-Payments but you selected some of both types.')) values['move_ids'] = [(6, 0, active_move_ids.ids)] return values