Files
odoo_source/addons/website_payment/models/payment_provider.py
T
william-andre 0479b2b594 [IMP] account,*: manage subsidiary companies
Allow sharing records between company
* accounts
* taxes
* fiscal positions
* products
* ...and some related models

These records can be read and used in children companies.

This can be used to
* have different branding for different businesses
* allow more complex security rules
* consolidate branches differently
* manage different tax reports with different tax ids in the same
  country

task-3371677

closes odoo/odoo#125642

Related: odoo/enterprise#43215
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2023-07-20 11:49:06 +02:00

39 lines
1.3 KiB
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.http import request
class PaymentProvider(models.Model):
_inherit = "payment.provider"
website_id = fields.Many2one(
"website",
check_company=True,
ondelete="restrict",
)
@api.model
def _get_compatible_providers(self, *args, website_id=None, **kwargs):
""" Override of `payment` to only return providers matching website-specific criteria.
In addition to the base criteria, the website must either not be set or be the same as the
one provided in the kwargs.
:param int website_id: The provided website, as a `website` id.
:return: The compatible providers.
:rtype: payment.provider
"""
providers = super()._get_compatible_providers(*args, website_id=website_id, **kwargs)
if website_id:
providers = providers.filtered(
lambda p: not p.website_id or p.website_id.id == website_id
)
return providers
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()