{"record":{"id":"00dc33b04c340fc9","repo":"odoo/odoo","slug":"you-can-t-delete-a-payment-method-that-is-linked-t","errorCode":null,"errorMessage":"You can't delete a payment method that is linked to a provider in the enabled or test state.\nLinked providers(s): %s","messagePattern":"You can't delete a payment method that is linked to a provider in the enabled or test state\\.\nLinked providers\\(s\\): (.+?)","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"addons/account_payment/models/account_payment_method_line.py","lineNumber":70,"sourceCode":"                        if journal_line.payment_method_id:\n                            if (\n                                manage_providers\n                                and method_information_mapping.get(journal_line.payment_method_id.id, {}).get('mode') == 'electronic'\n                            ):\n                                protected_provider_ids.add(journal_line.payment_provider_id.id)\n\n                candidates_provider_ids = provider_ids - protected_provider_ids\n                if candidates_provider_ids:\n                    line.payment_provider_id = next(iter(candidates_provider_ids))\n\n    @api.ondelete(at_uninstall=False)\n    def _unlink_except_active_provider(self):\n        \"\"\" Ensure we don't remove an account.payment.method.line that is linked to a provider\n        in the test or enabled state.\n        \"\"\"\n        active_provider = self.payment_provider_id.filtered(lambda provider: provider.state in ['enabled', 'test'])\n        if active_provider:\n            raise UserError(_(\n                \"You can't delete a payment method that is linked to a provider in the enabled \"\n                \"or test state.\\n\"\"Linked providers(s): %s\",\n                ', '.join(a.display_name for a in active_provider),\n            ))\n\n    def action_open_provider_form(self):\n        self.ensure_one()\n        return {\n            'type': 'ir.actions.act_window',\n            'name': _('Provider'),\n            'view_mode': 'form',\n            'res_model': 'payment.provider',\n            'target': 'current',\n            'res_id': self.payment_provider_id.id\n        }\n","sourceCodeStart":52,"sourceCodeEnd":86,"githubUrl":"https://github.com/odoo/odoo/blob/1e661df964b1b264c9cef3ab28430d4785be3fda/addons/account_payment/models/account_payment_method_line.py#L52-L86","documentation":"Error \"You can't delete a payment method that is linked to a provider in the enabled or test state.\nLinked providers(s): %s\" thrown in odoo/odoo.","triggerScenarios":"Thrown at addons/account_payment/models/account_payment_method_line.py:70 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Disable (or switch to test) the linked payment provider(s) first, then delete the payment method line."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1e661df964b1b264c9cef3ab28430d4785be3fda","analyzedAt":"2026-08-15T05:22:16.142Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}