[FIX] payment(_custom): provider uninstall

Since fd2fb212c5, the
sepa provider (enterprise module) behaves as a custom
provider but despite some adaptations, the removal
of providers on module uninstall was not properly
adapted.

The uninstall of the sepa provider failed as its
inline template was not unlinked from the provider
before the template deletion.

This commit makes sure that custom providers are
correctly considered in the uninstall util supposed
to restore a provider to its state before the
installation of its module.

opw-3734697
opw-3721846

closes odoo/odoo#153843

X-original-commit: e70dbbae56472b124a59c38a1fbfeea23c8ec28b
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Victor Feyens
2024-02-13 17:59:58 +00:00
parent c462d28e5b
commit 5bcb3e0cf6
2 changed files with 14 additions and 1 deletions
+5 -1
View File
@@ -636,6 +636,10 @@ class PaymentProvider(models.Model):
"""
return
@api.model
def _get_removal_domain(self, provider_code):
return [('code', '=', provider_code)]
@api.model
def _remove_provider(self, provider_code):
""" Remove the module-specific data of the given provider.
@@ -643,7 +647,7 @@ class PaymentProvider(models.Model):
:param str provider_code: The code of the provider whose data to remove.
:return: None
"""
providers = self.search([('code', '=', provider_code)])
providers = self.search(self._get_removal_domain(provider_code))
providers.write(self._get_removal_values())
def _get_removal_values(self):
@@ -1,6 +1,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, api, fields, models
from odoo.osv.expression import OR
class PaymentProvider(models.Model):
@@ -62,6 +63,14 @@ class PaymentProvider(models.Model):
f'<p><br></p>' \
f'</div>'
@api.model
def _get_removal_domain(self, provider_code):
return OR([
super()._get_removal_domain(provider_code),
[('code', '=', 'custom'), ('custom_mode', '=', provider_code)],
])
@api.model
def _get_removal_values(self):
""" Override of `payment` to nullify the `custom_mode` field. """
res = super()._get_removal_values()