From 5bcb3e0cf6e576ff8f754baab3e7c7d297dc39dd Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Mon, 12 Feb 2024 16:15:25 +0100 Subject: [PATCH] [FIX] payment(_custom): provider uninstall Since fd2fb212c50952ca5a8e162ba5d82ce433cd5989, 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) --- addons/payment/models/payment_provider.py | 6 +++++- addons/payment_custom/models/payment_provider.py | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/payment/models/payment_provider.py b/addons/payment/models/payment_provider.py index f92dfd67ed7..6de3adb3069 100644 --- a/addons/payment/models/payment_provider.py +++ b/addons/payment/models/payment_provider.py @@ -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): diff --git a/addons/payment_custom/models/payment_provider.py b/addons/payment_custom/models/payment_provider.py index 158903ab993..ffd005bc0ad 100644 --- a/addons/payment_custom/models/payment_provider.py +++ b/addons/payment_custom/models/payment_provider.py @@ -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'


' \ f'' + @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()