# Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import _, api, fields, models from odoo.tools import is_html_empty class PaymentProvider(models.Model): _inherit = 'payment.provider' _sql_constraints = [( 'custom_providers_setup', "CHECK(custom_mode IS NULL OR (code = 'custom' AND custom_mode IS NOT NULL))", "Only custom providers should have a custom mode." )] code = fields.Selection( selection_add=[('custom', "Custom")], ondelete={'custom': 'set default'} ) custom_mode = fields.Selection( string="Custom Mode", selection=[('wire_transfer', "Wire Transfer")], required_if_provider='custom', ) qr_code = fields.Boolean( string="Enable QR Codes", help="Enable the use of QR-codes when paying by wire transfer.") @api.depends('code') def _compute_view_configuration_fields(self): """ Override of payment to hide the credentials page. :return: None """ super()._compute_view_configuration_fields() self.filtered(lambda p: p.code == 'custom').update({ 'show_credentials_page': False, 'show_payment_icon_ids': False, 'show_pre_msg': False, 'show_done_msg': False, 'show_cancel_msg': False, }) def _transfer_ensure_pending_msg_is_set(self): transfer_providers_without_msg = self.filtered( lambda p: p.code == 'custom' and p.custom_mode == 'wire_transfer' and is_html_empty(p.pending_msg) ) if not transfer_providers_without_msg: return # Don't bother translating the messages. account_payment_module = self.env['ir.module.module']._get('account_payment') if account_payment_module.state != 'installed': transfer_providers_without_msg.pending_msg = f'
{_("Please use the order name as communication reference.")}
' \ f'{_("Please use the order name as communication reference.")}
' \ f'