odoo/odoo · error · UserError

You can't delete a payment method that is linked to a provid

Error message

You can't delete a payment method that is linked to a provider in the enabled or test state.
Linked providers(s): %s

What it means

Error "You can't delete a payment method that is linked to a provider in the enabled or test state. Linked providers(s): %s" thrown in odoo/odoo.

Source

Thrown at addons/account_payment/models/account_payment_method_line.py:70

                        if journal_line.payment_method_id:
                            if (
                                manage_providers
                                and method_information_mapping.get(journal_line.payment_method_id.id, {}).get('mode') == 'electronic'
                            ):
                                protected_provider_ids.add(journal_line.payment_provider_id.id)

                candidates_provider_ids = provider_ids - protected_provider_ids
                if candidates_provider_ids:
                    line.payment_provider_id = next(iter(candidates_provider_ids))

    @api.ondelete(at_uninstall=False)
    def _unlink_except_active_provider(self):
        """ Ensure we don't remove an account.payment.method.line that is linked to a provider
        in the test or enabled state.
        """
        active_provider = self.payment_provider_id.filtered(lambda provider: provider.state in ['enabled', 'test'])
        if active_provider:
            raise UserError(_(
                "You can't delete a payment method that is linked to a provider in the enabled "
                "or test state.\n""Linked providers(s): %s",
                ', '.join(a.display_name for a in active_provider),
            ))

    def action_open_provider_form(self):
        self.ensure_one()
        return {
            'type': 'ir.actions.act_window',
            'name': _('Provider'),
            'view_mode': 'form',
            'res_model': 'payment.provider',
            'target': 'current',
            'res_id': self.payment_provider_id.id
        }

View on GitHub (pinned to 1e661df964)

Solutions

  1. Disable (or switch to test) the linked payment provider(s) first, then delete the payment method line.

When it happens

Trigger: Thrown at addons/account_payment/models/account_payment_method_line.py:70 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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