odoo/odoo · error · UserError

You can only resequence items from the same journal

Error message

You can only resequence items from the same journal

What it means

account.resequence.wizard.default_get refuses to resequence entries coming from more than one journal (len(active_move_ids.journal_id) > 1). Resequencing renumbers entries within a journal's sequence; mixing journals would make the resulting numbering ambiguous, so the wizard blocks it immediately.

Source

Thrown at addons/account/wizard/account_resequence.py:33

    sequence_number_reset = fields.Char(compute='_compute_sequence_number_reset')
    first_date = fields.Date(help="Date (inclusive) from which the numbers are resequenced.")
    end_date = fields.Date(help="Date (inclusive) to which the numbers are resequenced. If not set, all Journal Entries up to the end of the period are resequenced.")
    first_name = fields.Char(compute="_compute_first_name", readonly=False, store=True, required=True, string="First New Sequence")
    ordering = fields.Selection([('keep', 'Keep current order'), ('date', 'Reorder by accounting date')], required=True, default='keep')
    move_ids = fields.Many2many('account.move')
    new_values = fields.Text(compute='_compute_new_values')
    preview_moves = fields.Text(compute='_compute_preview_moves')

    @api.model
    def default_get(self, fields):
        values = super().default_get(fields)
        if 'move_ids' not in fields:
            return values
        active_move_ids = self.env['account.move']
        if self.env.context['active_model'] == 'account.move' and 'active_ids' in self.env.context:
            active_move_ids = self.env['account.move'].browse(self.env.context['active_ids'])
        if len(active_move_ids.journal_id) > 1:
            raise UserError(_('You can only resequence items from the same journal'))
        move_types = set(active_move_ids.mapped('move_type'))
        if (
            active_move_ids.journal_id.refund_sequence
            and ('in_refund' in move_types or 'out_refund' in move_types)
            and len(move_types) > 1
        ):
            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.origin_payment_id)))
        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

    @api.depends('first_name')
    def _compute_sequence_number_reset(self):

View on GitHub (pinned to 1e661df964)

Solutions

  1. Filter the entries list by a single journal before launching Resequence.
  2. Run the wizard once per journal: split the selection on move.journal_id.
  3. In code, pre-group: for journal, moves in groupby(moves, key=lambda m: m.journal_id) and call the wizard per group.

Example fix

# before
self.env['account.resequence.wizard'].with_context(
    active_model='account.move', active_ids=moves.ids,  # multi-journal
).create({})

# after
from itertools import groupby
for journal, grouped in groupby(moves.sorted('journal_id'), key=lambda m: m.journal_id):
    self.env['account.resequence.wizard'].with_context(
        active_model='account.move',
        active_ids=self.env['account.move'].concat(*grouped).ids,
    ).create({})
Defensive patterns

Strategy: validation

Validate before calling

if len(moves.journal_id) > 1:
    moves = moves.filtered(lambda m: m.journal_id == moves[0].journal_id)  # or split per journal

Prevention

When it happens

Trigger: Selecting account.move records from two different journals (e.g. two customer invoices journals, or an invoice journal and a bank journal) and running the 'Resequence' action; the check uses the journals of all active_ids passed in context.

Common situations: Multi-journal list views where the journal column isn't visible; users selecting by date range across journals; automation passing unfiltered move ids to the wizard.

Related errors


AI-assisted analysis of odoo/odoo@1e661df964 (2026-08-15). Data as JSON: /api/errors/df47063130d82828. Report an issue: GitHub.