Skip to content

Commit 6deba5e

Browse files
xaviedoanhduyAntoineVDV
authored andcommitted
[FIX] {account,website}_payment: filter providers per website
closes odoo#218089 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
1 parent 0448338 commit 6deba5e

5 files changed

Lines changed: 31 additions & 3 deletions

File tree

addons/account_payment/controllers/portal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def _invoice_get_page_view_values(self, invoice, access_token, **kwargs):
3030
invoice_company.id,
3131
partner_sudo.id,
3232
invoice.amount_total,
33-
currency_id=invoice.currency_id.id
33+
currency_id=invoice.currency_id.id,
34+
**kwargs,
3435
) # In sudo mode to read the fields of providers and partner (if logged out).
3536
payment_methods_sudo = request.env['payment.method'].sudo()._get_compatible_payment_methods(
3637
providers_sudo.ids,

addons/sale/tests/test_payment_flow.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Part of Odoo. See LICENSE file for full copyright and licensing details.
22

3-
from unittest.mock import ANY, patch
3+
from unittest.mock import patch
44

55
from odoo.exceptions import AccessError
66
from odoo.tests import JsonRpcException, tagged
@@ -39,7 +39,8 @@ def test_11_so_payment_link(self):
3939
'._compute_show_tokenize_input_mapping'
4040
) as patched:
4141
tx_context = self._get_portal_pay_context(**route_values)
42-
patched.assert_called_once_with(ANY, sale_order_id=ANY)
42+
patched.assert_called_once()
43+
self.assertIn('sale_order_id', patched.call_args[1])
4344

4445
self.assertEqual(tx_context['currency_id'], self.sale_order.currency_id.id)
4546
self.assertEqual(tx_context['partner_id'], self.sale_order.partner_invoice_id.id)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
22
# Part of Odoo. See LICENSE file for full copyright and licensing details.
33

4+
from . import payment
45
from . import portal
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from odoo.http import request, route
4+
5+
from odoo.addons.account_payment.controllers import payment as account_payment
6+
7+
8+
class PaymentPortal(account_payment.PaymentPortal):
9+
10+
@route()
11+
def payment_pay(self, *args, **kwargs):
12+
"""Override of `payment` to make the provider filtering website-aware."""
13+
return super().payment_pay(*args, website_id=request.website.id, **kwargs)
14+
15+
@route()
16+
def payment_method(self, **kwargs):
17+
"""Override of `payment` to make the provider filtering website-aware."""
18+
return super().payment_method(website_id=request.website.id, **kwargs)

addons/website_payment/controllers/portal.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from odoo.http import request
77
from odoo.tools.json import scriptsafe as json_safe
88

9+
from odoo.addons.account_payment.controllers import portal as account_payment_portal
910
from odoo.addons.payment import utils as payment_utils
1011
from odoo.addons.payment.controllers import portal as payment_portal
1112

@@ -151,3 +152,9 @@ def _compute_show_tokenize_input_mapping(providers_sudo, **kwargs):
151152
for provider_sudo in providers_sudo:
152153
res[provider_sudo.id] = False
153154
return res
155+
156+
157+
class PortalAccount(account_payment_portal.PortalAccount):
158+
def _invoice_get_page_view_values(self, *args, **kwargs):
159+
"""Override of `account_payment` to make the providers filtering website-aware."""
160+
return super()._invoice_get_page_view_values(*args, website_id=request.website.id, **kwargs)

0 commit comments

Comments
 (0)