Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Invoicing
Entity: res.partner.bank
Compute Method: _compute_phishing_warnings
| Inputs | Method | Outputs |
|---|---|---|
|
+ warnings_common_data = { + 'level': 'danger', + 'action_text': self.env._("Learn more"), + 'action': { + 'type': 'ir.actions.act_url', + 'url': 'https://www.odoo.com/documentation/latest/applications/finance/accounting/payables/pay/trusted_accounts.html', + 'target': 'new', + }, + } + code_to_country_id = dict(self.env['res.country']._read_group( + domain=[('code', 'in', iban_accounts.mapped(lambda account: account.sanitized_account_number[:2]))], + groupby=['code'], + aggregates=['id:recordset'], + )) if (iban_accounts := self.filtered(lambda account: account.account_type == 'iban')) else {} + for account in self: + warnings = {} + if not account.allow_out_payment and account.sanitized_account_number: + if account.account_type == 'iban' and (bank_institution_code := account.sanitized_account_number[4:7]) and (money_transfer_service := account._get_money_transfer_services().get(bank_institution_code)): + warnings['service_not_bank'] = { + 'message': self.env._( + "Phishing risk: %(money_transfer_service)s is a money transfer service and not a bank. Double check if the account can be trusted by calling the vendor.", + money_transfer_service=money_transfer_service, + ), + **warnings_common_data, + } + + labels_and_countries = [ + (self.env._("IBAN"), account.account_type == 'iban' and code_to_country_id.get(account.sanitized_account_number[:2])), + (self.env._("CLABE"), account.account_type == 'clabe' and self.env.ref('base.mx')), + (self.env._("Account Holder"), account.partner_id.country_id), + (self.env._("Bank Account"), account.country_id), + ] + for idx, (label1, country1) in enumerate(labels_and_countries, 1): + if 'countries_mismatch' in warnings: + break + for label2, country2 in labels_and_countries[idx:]: + if country1 and country2 and country1 != country2: + warnings['countries_mismatch'] = { + 'message': self.env._( + "Phishing risk: %(label1)s is in %(country1)s but %(label2)s is in %(country2)s", + label1=label1, + country1=country1.name, + label2=label2, + country2=country2.name, + ), + **warnings_common_data, + } + break + + account.phishing_warnings = warnings |
|
