Skip to content

Commit

Permalink
[FIX] website_sale, website_quote: display payment acquirers per country
Browse files Browse the repository at this point in the history
Commit 542201e added the possibility to configure a set of countries for a
given payment acquirer.
Commit 194d52e refactored the payment form, but forgot to take the country
into acount.

opw 1837819
  • Loading branch information
len-odoo authored and len-foss committed Apr 27, 2018
1 parent d88c370 commit 0050019
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion addons/website_quote/controllers/main.py
Expand Up @@ -8,6 +8,7 @@
from odoo.addons.portal.controllers.portal import get_records_pager
from odoo.addons.sale.controllers.portal import CustomerPortal
from odoo.addons.portal.controllers.mail import _message_post_helper
from odoo.osv import expression


class CustomerPortal(CustomerPortal):
Expand Down Expand Up @@ -89,7 +90,11 @@ def view(self, order_id, pdf=None, token=None, message=False, **post):
}

if order_sudo.require_payment or values['need_payment']:
acquirers = request.env['payment.acquirer'].sudo().search([('website_published', '=', True), ('company_id', '=', order_sudo.company_id.id)])
domain = expression.AND([
['&', ('website_published', '=', True), ('company_id', '=', order_sudo.company_id.id)],
['|', ('specific_countries', '=', False), ('country_ids', 'in', [order_sudo.partner_id.country_id.id])]
])
acquirers = request.env['payment.acquirer'].sudo().search(domain)

values['form_acquirers'] = [acq for acq in acquirers if acq.payment_flow == 'form' and acq.view_template_id]
values['s2s_acquirers'] = [acq for acq in acquirers if acq.payment_flow == 's2s' and acq.registration_view_template_id]
Expand Down
9 changes: 6 additions & 3 deletions addons/website_sale/controllers/main.py
Expand Up @@ -12,6 +12,7 @@
from odoo.exceptions import ValidationError
from odoo.addons.website.controllers.main import Website
from odoo.addons.website_form.controllers.main import WebsiteForm
from odoo.osv import expression

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -756,9 +757,11 @@ def _get_shop_payment_values(self, order, **kwargs):
bootstrap_formatting= True
)

acquirers = request.env['payment.acquirer'].search(
[('website_published', '=', True), ('company_id', '=', order.company_id.id)]
)
domain = expression.AND([
['&', ('website_published', '=', True), ('company_id', '=', order.company_id.id)],
['|', ('specific_countries', '=', False), ('country_ids', 'in', [order.partner_id.country_id.id])]
])
acquirers = request.env['payment.acquirer'].search(domain)

values['access_token'] = order.access_token
values['form_acquirers'] = [acq for acq in acquirers if acq.payment_flow == 'form' and acq.view_template_id]
Expand Down

0 comments on commit 0050019

Please sign in to comment.