{"record":{"id":"b34c813a8344bea6","repo":"odoo/odoo","slug":"the-register-payment-wizard-should-only-be-called","errorCode":null,"errorMessage":"The register payment wizard should only be called on account.move or account.move.line records.","messagePattern":"The register payment wizard should only be called on account\\.move or account\\.move\\.line records\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"addons/account/wizard/account_payment_register.py","lineNumber":947,"sourceCode":"    # -------------------------------------------------------------------------\n    # LOW-LEVEL METHODS\n    # -------------------------------------------------------------------------\n\n    @api.model\n    def default_get(self, fields):\n        # OVERRIDE\n        res = super().default_get(fields)\n\n        if 'line_ids' in fields and 'line_ids' not in res:\n\n            # Retrieve moves to pay from the context.\n\n            if self.env.context.get('active_model') == 'account.move':\n                lines = self.env['account.move'].browse(self.env.context.get('active_ids', [])).line_ids\n            elif self.env.context.get('active_model') == 'account.move.line':\n                lines = self.env['account.move.line'].browse(self.env.context.get('active_ids', []))\n            else:\n                raise UserError(_(\n                    \"The register payment wizard should only be called on account.move or account.move.line records.\"\n                ))\n\n            if 'journal_id' in res and not self.env['account.journal'].browse(res['journal_id']).filtered_domain([\n                *self.env['account.journal']._check_company_domain(lines.company_id),\n                ('type', 'in', ('bank', 'cash', 'credit')),\n            ]):\n                # default can be inherited from the list view, should be computed instead\n                del res['journal_id']\n\n            # Keep lines having a residual amount to pay.\n            available_lines = self.env['account.move.line']\n            valid_account_types = self.env['account.payment']._get_valid_payment_account_types()\n            for line in lines:\n\n                if line.account_type not in valid_account_types:\n                    continue\n                if line.currency_id:","sourceCodeStart":929,"sourceCodeEnd":965,"githubUrl":"https://github.com/odoo/odoo/blob/1e661df964b1b264c9cef3ab28430d4785be3fda/addons/account/wizard/account_payment_register.py#L929-L965","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nctx = {'active_model': 'my.custom.model', 'active_ids': records.ids}\nself.env['account.payment.register'].with_context(**ctx).create({})\n\n# after\nctx = {'active_model': 'account.move', 'active_ids': move_ids.ids}\nself.env['account.payment.register'].with_context(**ctx).create({})","handlingStrategy":"validation","validationCode":"assert self.env.context.get('active_model') in ('account.move', 'account.move.line'), \\\n    'register payment requires account.move or account.move.line context'\nwizard = self.env['account.payment.register'].with_context(\n    active_model='account.move', active_ids=move_ids.ids,\n).create({})","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["accounting","payments","context","wizard","odoo"],"backgroundTag":null,"analyzedSha":"1e661df964b1b264c9cef3ab28430d4785be3fda","analyzedAt":"2026-08-15T05:22:16.142Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}