diff --git a/addons/payment/models/payment_provider.py b/addons/payment/models/payment_provider.py index 50e20dc1981..abec35a96a8 100644 --- a/addons/payment/models/payment_provider.py +++ b/addons/payment/models/payment_provider.py @@ -589,7 +589,23 @@ class PaymentProvider(models.Model): :return: None """ providers = self.search([('code', '=', provider_code)]) - providers.write({ + providers.write(self._get_removal_values()) + + def _get_removal_values(self): + """ Return the values to update a provider with when its module is uninstalled. + + For a module to specify additional removal values, it must override this method and complete + the generic values with its specific values. + + :return: The removal values to update the removed provider with. + :rtype: dict + """ + return { 'code': 'none', 'state': 'disabled', - }) + 'is_published': False, + 'redirect_form_view_id': None, + 'inline_form_view_id': None, + 'token_inline_form_view_id': None, + 'express_checkout_form_view_id': None, + } diff --git a/addons/payment_custom/models/payment_provider.py b/addons/payment_custom/models/payment_provider.py index ae7844cf8ce..f83213708cd 100644 --- a/addons/payment_custom/models/payment_provider.py +++ b/addons/payment_custom/models/payment_provider.py @@ -71,3 +71,9 @@ class PaymentProvider(models.Model): f'

{_("Communication")}

' \ f'

{_("Please use the order name as communication reference.")}

' \ f'' + + def _get_removal_values(self): + """ Override of `payment` to nullify the `custom_mode` field. """ + res = super()._get_removal_values() + res['custom_mode'] = None + return res