Files
odoo_source/addons/website_sale_picking/models/payment_provider.py
T
Horacio Tellez f7b8f07501 [IMP] payment: rename of acquirer to provider
Changing the name of model payment.acquirer to payment.provider
and everything that it touches. It is technically incorrect to
use the term "acquirer" for systems that only provide a service
of payment.
After this commit the model payment.acquirer and all related to
it will be renamed to payment.provider.

Task - 2842088

closes odoo/odoo#90899

Related: odoo/upgrade#3542
Related: odoo/documentation#1981
Related: odoo/enterprise#27131
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-09-09 13:38:08 +02:00

45 lines
1.7 KiB
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class PaymentProvider(models.Model):
_inherit = 'payment.provider'
custom_mode = fields.Selection(
selection_add=[('onsite', "On Site")]
)
@api.model
def _get_compatible_providers(self, *args, sale_order_id=None, website_id=None, **kwargs):
""" Override of payment to exclude onsite providers if the delivery doesn't match.
:param int sale_order_id: The sale order to be paid, if any, as a `sale.order` id
:param int website_id: The provided website, as a `website` id
:return: The compatible providers
:rtype: recordset of `payment.provider`
"""
compatible_providers = super()._get_compatible_providers(
*args, sale_order_id=sale_order_id, website_id=website_id, **kwargs)
# Show on site picking only if delivery carriers onsite exists
onsite_carriers = self.env['delivery.carrier'].search([
('website_published', '=', True),
('delivery_type', '=', 'onsite'),
'|',
('website_id', '=?', website_id),
('website_id', '=', False)
])
order = self.env['sale.order'].browse(sale_order_id).exists()
# Show onsite providers only if onsite carriers exists
# and the order contains physical products
if not onsite_carriers or not any(
product.type in ('consu', 'product')
for product in order.order_line.product_id
):
compatible_providers.filtered(
lambda p: p.code != 'custom' or p.custom_mode != 'onsite'
)
return compatible_providers