# Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import _, api, fields, models from odoo.osv.expression import AND from odoo.addons.payment_custom import const 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.model_create_multi def create(self, values_list): providers = super().create(values_list) providers.filtered(lambda p: p.custom_mode == 'wire_transfer').pending_msg = None return providers def action_recompute_pending_msg(self): """ Recompute the pending message to include the existing bank accounts. """ account_payment_module = self.env['ir.module.module']._get('account_payment') if account_payment_module.state == 'installed': for provider in self.filtered(lambda p: p.custom_mode == 'wire_transfer'): company_id = provider.company_id.id accounts = self.env['account.journal'].search([ *self.env['account.journal']._check_company_domain(company_id), ('type', '=', 'bank'), ]).bank_account_id account_names = "".join(f"
{account.display_name}