[FIX] payment, payment_custom: uninstall crash of payment modules

Before this commit a constraint between the `ir_ui_view` and
`payment_provider` view made impossible for providers to be
uninstalled. After this commit the constraint is correctly treated.

A similar issue is found on a constraint on the `payment_custom`
module. To fix this and future possible problems we added the
possibility to modify the way providers are uninstalled following
each provider needs.

Task - 3002532

closes odoo/odoo#102951

X-original-commit: 56318826b758f09782c8f67c05a7a46789cff47d
Related: odoo/documentation#2802
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
Horacio Tellez
2022-10-10 19:03:23 +02:00
committed by Antoine Vandevenne (anv)
parent 39c5904b4a
commit 4c51ab0048
2 changed files with 24 additions and 2 deletions
+18 -2
View File
@@ -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,
}
@@ -71,3 +71,9 @@ class PaymentProvider(models.Model):
f'<h4>{_("Communication")}</h4>' \
f'<p>{_("Please use the order name as communication reference.")}</p>' \
f'</div>'
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