feat: separate fusion field service and LTC into standalone modules, update core modules
- fusion_claims: separated field service logic, updated controllers/views - fusion_tasks: updated task views and map integration - fusion_authorizer_portal: added page 11 signing, schedule booking, migrations - fusion_shipping: new standalone shipping module (Canada Post, FedEx, DHL, Purolator) - fusion_ltc_management: new standalone LTC management module
This commit is contained in:
39
fusion_shipping/models/payment_provider.py
Normal file
39
fusion_shipping/models/payment_provider.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from odoo import _, api, models
|
||||
|
||||
from odoo.addons.payment import utils as payment_utils
|
||||
|
||||
|
||||
class PaymentProvider(models.Model):
|
||||
_inherit = 'payment.provider'
|
||||
|
||||
@api.model
|
||||
def _get_compatible_providers(self, *args, sale_order_id=None, report=None, **kwargs):
|
||||
""" Override of payment to allow only COD providers if allow_cash_on_delivery is enabled for
|
||||
selected UPS delivery method.
|
||||
|
||||
:param int sale_order_id: The sales order to be paid, if any, as a `sale.order` id.
|
||||
:param dict report: The availability report.
|
||||
:return: The compatible providers.
|
||||
:rtype: payment.provider
|
||||
"""
|
||||
compatible_providers = super()._get_compatible_providers(
|
||||
*args, sale_order_id=sale_order_id, report=report, **kwargs
|
||||
)
|
||||
|
||||
sale_order = self.env['sale.order'].browse(sale_order_id).exists()
|
||||
if (
|
||||
sale_order.carrier_id.delivery_type in ('fusion_ups', 'fusion_ups_rest')
|
||||
and sale_order.carrier_id.allow_cash_on_delivery
|
||||
):
|
||||
unfiltered_providers = compatible_providers
|
||||
compatible_providers = compatible_providers.filtered(
|
||||
lambda p: p.custom_mode == 'cash_on_delivery'
|
||||
)
|
||||
payment_utils.add_to_report(
|
||||
report,
|
||||
unfiltered_providers - compatible_providers,
|
||||
available=False,
|
||||
reason=_("UPS provider is configured to use only Collect on Delivery."),
|
||||
)
|
||||
|
||||
return compatible_providers
|
||||
Reference in New Issue
Block a user