[FIX] payment, sale: forward kwargs to _get_compatible_payment_methods

The keyword arguments of the callees were never forwarded to the
`payment.method::_get_compatible_payment_methods` method, preventing
overriding modules from controlling which payment method should be
available depending on the kwargs.

task-3640488

Part-of: odoo/odoo#150120
This commit is contained in:
Antoine Vandevenne (anv)
2024-02-20 13:22:08 +00:00
parent 524ec9062e
commit e475a38da2
3 changed files with 5 additions and 1 deletions
+1
View File
@@ -116,6 +116,7 @@ class PaymentPortal(portal.CustomerPortal):
providers_sudo.ids,
partner_sudo.id,
currency_id=currency.id,
**kwargs,
) # In sudo mode to read the fields of providers.
tokens_sudo = request.env['payment.token'].sudo()._get_available_tokens(
providers_sudo.ids, partner_sudo.id
+2 -1
View File
@@ -185,7 +185,7 @@ class PaymentMethod(models.Model):
def _get_compatible_payment_methods(
self, provider_ids, partner_id, currency_id=None, force_tokenization=False,
is_express_checkout=False
is_express_checkout=False, **kwargs
):
""" Search and return the payment methods matching the compatibility criteria.
@@ -201,6 +201,7 @@ class PaymentMethod(models.Model):
:param bool force_tokenization: Whether only payment methods supporting tokenization can be
matched.
:param bool is_express_checkout: Whether the payment is made through express checkout.
:param dict kwargs: Optional data. This parameter is not used here.
:return: The compatible payment methods.
:rtype: payment.method
"""
+2
View File
@@ -219,6 +219,8 @@ class CustomerPortal(payment_portal.PaymentPortal):
providers_sudo.ids,
partner_sudo.id,
currency_id=currency.id,
sale_order_id=order_sudo.id,
**kwargs,
) # In sudo mode to read the fields of providers.
tokens_sudo = request.env['payment.token'].sudo()._get_available_tokens(
providers_sudo.ids, partner_sudo.id, **kwargs