mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-24 07:52:04 +02:00
19.0 vanilla
This commit is contained in:
parent
d1963a3c3a
commit
2d3ee4855a
7430 changed files with 2687981 additions and 2965473 deletions
32
odoo-bringout-oca-ocb-payment/payment/models/res_country.py
Normal file
32
odoo-bringout-oca-ocb-payment/payment/models/res_country.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
# Import the payment provider modules with aliases to avoid circular import errors.
|
||||
try:
|
||||
import odoo.addons.payment_mercado_pago as mercado_pago
|
||||
import odoo.addons.payment_stripe as stripe
|
||||
except ModuleNotFoundError:
|
||||
mercado_pago = None
|
||||
stripe = None
|
||||
|
||||
|
||||
class ResCountry(models.Model):
|
||||
_inherit = 'res.country'
|
||||
|
||||
is_mercado_pago_supported_country = fields.Boolean(compute='_compute_provider_support')
|
||||
is_stripe_supported_country = fields.Boolean(compute='_compute_provider_support')
|
||||
|
||||
@api.depends('code')
|
||||
def _compute_provider_support(self):
|
||||
for country in self:
|
||||
country.is_stripe_supported_country = (
|
||||
stripe is not None
|
||||
and stripe.const.COUNTRY_MAPPING.get(
|
||||
country.code, country.code
|
||||
) in stripe.const.SUPPORTED_COUNTRIES
|
||||
)
|
||||
country.is_mercado_pago_supported_country = (
|
||||
mercado_pago
|
||||
and country.code in mercado_pago.const.SUPPORTED_COUNTRIES
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue