Before this commit, `get_base_url()` could not be called on an empty recordset. It might be called on an empty recordset for instance when getting the paypal payment endpoint URLs. This commit allows that and returns the ICP value in that case. The goal is to always use the util method `get_base_url()` instead of directly accessing the ICP. closes odoo/odoo#68201 Related: odoo/enterprise#17538 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
21 lines
560 B
Python
21 lines
560 B
Python
# coding: utf-8
|
|
|
|
from odoo import fields, models
|
|
from odoo.http import request
|
|
|
|
|
|
class PaymentAcquirer(models.Model):
|
|
_inherit = "payment.acquirer"
|
|
|
|
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:
|
|
return request.httprequest.url_root
|
|
return super().get_base_url()
|