odoo/odoo · error · UserError
The register payment wizard should only be called on account
Error message
The register payment wizard should only be called on account.move or account.move.line records.
What it means
account.payment.register.default_get raises this when the wizard is opened with an active_model that is neither 'account.move' nor 'account.move.line'. The wizard resolves which journal items to pay exclusively from those two context keys; any other model means it was invoked from the wrong action or with a hand-built context.
Source
Thrown at addons/account/wizard/account_payment_register.py:947
# -------------------------------------------------------------------------
# LOW-LEVEL METHODS
# -------------------------------------------------------------------------
@api.model
def default_get(self, fields):
# OVERRIDE
res = super().default_get(fields)
if 'line_ids' in fields and 'line_ids' not in res:
# Retrieve moves to pay from the context.
if self.env.context.get('active_model') == 'account.move':
lines = self.env['account.move'].browse(self.env.context.get('active_ids', [])).line_ids
elif self.env.context.get('active_model') == 'account.move.line':
lines = self.env['account.move.line'].browse(self.env.context.get('active_ids', []))
else:
raise UserError(_(
"The register payment wizard should only be called on account.move or account.move.line records."
))
if 'journal_id' in res and not self.env['account.journal'].browse(res['journal_id']).filtered_domain([
*self.env['account.journal']._check_company_domain(lines.company_id),
('type', 'in', ('bank', 'cash', 'credit')),
]):
# default can be inherited from the list view, should be computed instead
del res['journal_id']
# Keep lines having a residual amount to pay.
available_lines = self.env['account.move.line']
valid_account_types = self.env['account.payment']._get_valid_payment_account_types()
for line in lines:
if line.account_type not in valid_account_types:
continue
if line.currency_id:View on GitHub (pinned to 1e661df964)
Solutions
- Open the wizard from a customer/vendor bill or the account.move list view ('Register Payment' action) so active_model is account.move.
- In code, always pass with_context(active_model='account.move', active_ids=move_ids.ids) (or 'account.move.line' with line ids).
- For custom models, don't reuse this wizard; build payment values with env['account.payment'] / account.payment.register manually after setting line_ids.
Example fix
# before
ctx = {'active_model': 'my.custom.model', 'active_ids': records.ids}
self.env['account.payment.register'].with_context(**ctx).create({})
# after
ctx = {'active_model': 'account.move', 'active_ids': move_ids.ids}
self.env['account.payment.register'].with_context(**ctx).create({}) Defensive patterns
Strategy: validation
Validate before calling
assert self.env.context.get('active_model') in ('account.move', 'account.move.line'), \
'register payment requires account.move or account.move.line context'
wizard = self.env['account.payment.register'].with_context(
active_model='account.move', active_ids=move_ids.ids,
).create({}) Prevention
- Never build the wizard context by hand without active_model; copy it from a real browser action.
- Bind custom actions to account.move/account.move.line only.
When it happens
Trigger: Launching the wizard from an act_window/server action bound to another model (e.g. account.payment.list or a custom model), or calling self.env['account.payment.register'].with_context(active_model='other.model', active_ids=[...]).default_get([...]) in code.
Common situations: Custom modules that try to reuse the register-payment wizard from their own views; copy-pasted XML actions where the binding model was changed; RPC scripts omitting active_model entirely while passing active_ids.
Related errors
- You can't open the register payment wizard without at least
- Missing 'active_model' in context.
- You can't have two payment method lines of the same payment
- Some payment methods supposed to be unique already exists so
- Percentage must be between 0 and 100
AI-assisted analysis of odoo/odoo@1e661df964 (2026-08-15).
Data as JSON: /api/errors/b34c813a8344bea6.
Report an issue: GitHub.