summaryrefslogtreecommitdiff
path: root/addons/payment/models/payment_acquirer.py
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2020-06-19 11:45:10 +0000
committerNicolas Martinelli <nim@odoo.com>2020-06-23 08:27:29 +0000
commit7a4e90de8aef581cb78ddfbd3cb5f5abcc1137ec (patch)
treea79958cec6c7ff3020ecf6d09ae6085039731ad9 /addons/payment/models/payment_acquirer.py
parent9e60a82680259cd5125738da21fb9e4b82eabc34 (diff)
[FIX] account_payment, payment: filter providers
- Install 3 payment providers: P1: no countries set P2: country set to USA P3: country set to Canada - Activate online payment of invoices - Create an invoice for portal user A (country of user is USA) - Login with A - Pay the invoice All 3 providers are available, while only 1 & 2 should be available. The providers are filtered in the sale module, but not in the account module: https://github.com/odoo/odoo/blob/586ee04a6296c13868011b3afaca61be5c6ff3c6/addons/sale/controllers/portal.py#L190-L193 The same issue occurs with the direct link `/website_payment/pay`. We apply the same filtering in all modules. opw-2279710 closes odoo/odoo#53483 X-original-commit: aaac93b551e2a5f331dd14ee5aefbe4ced173691 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'addons/payment/models/payment_acquirer.py')
-rw-r--r--addons/payment/models/payment_acquirer.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py
index c529688356f..2e605b71b0a 100644
--- a/addons/payment/models/payment_acquirer.py
+++ b/addons/payment/models/payment_acquirer.py
@@ -13,6 +13,7 @@ from odoo.exceptions import ValidationError
from odoo.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
from odoo.tools.misc import formatLang
from odoo.http import request
+from odoo.osv import expression
_logger = logging.getLogger(__name__)
@@ -343,7 +344,12 @@ class PaymentAcquirer(models.Model):
company = self.env.company
if not partner:
partner = self.env.user.partner_id
- active_acquirers = self.search([('state', 'in', ['enabled', 'test']), ('company_id', '=', company.id)])
+
+ domain = expression.AND([
+ ['&', ('state', 'in', ['enabled', 'test']), ('company_id', '=', company.id)],
+ ['|', ('country_ids', '=', False), ('country_ids', 'in', [partner.country_id.id])]
+ ])
+ active_acquirers = self.search(domain)
acquirers = active_acquirers.filtered(lambda acq: (acq.payment_flow == 'form' and acq.view_template_id) or
(acq.payment_flow == 's2s' and acq.registration_view_template_id))
return {