oca-ocb-core/odoo-bringout-oca-ocb-payment/payment/models/res_country.py
Ernad Husremovic 2d3ee4855a 19.0 vanilla
2026-03-09 09:30:27 +01:00

32 lines
1.1 KiB
Python

# 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
)