33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
# coding: utf-8
|
|
|
|
from werkzeug.urls import iri_to_uri
|
|
|
|
from odoo import fields, models
|
|
from odoo.http import request
|
|
|
|
|
|
class PaymentProvider(models.Model):
|
|
_inherit = "payment.provider"
|
|
|
|
website_id = fields.Many2one(
|
|
"website",
|
|
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
|
|
ondelete="restrict",
|
|
)
|
|
|
|
def get_base_url(self):
|
|
# Give priority to url_root to handle multi-website cases
|
|
if request and request.httprequest.url_root:
|
|
# Some domain names can use non-Latin script or alphabet or the Latin
|
|
# alphabet-based characters with diacritics or ligatures. They are
|
|
# stored as ASCII strings using Punycode transcription in the DNS
|
|
# system and need to be converted to send to external APIs.
|
|
return iri_to_uri(request.httprequest.url_root)
|
|
return super().get_base_url()
|
|
|
|
def copy(self, default=None):
|
|
res = super().copy(default=default)
|
|
if self._context.get('stripe_connect_onboarding'):
|
|
res.website_id = False
|
|
return res
|