Skip to content
Snippets Groups Projects
Commit 02dfd4fe authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] l10n_us: ABA/Routing number

Edit/create a bank account:
- Add a correct ABA number => nothing is displayed
- Add an incorrect number (e.g. with letters) => it crashes

Combining an `Integer` field with a `char` widget is just a bad idea...

opw-781069
parent 45958ab3
No related branches found
No related tags found
No related merge requests found
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_us
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0\n"
"Project-Id-Version: Odoo Server 11.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-07 14:56+0000\n"
"PO-Revision-Date: 2015-09-07 14:56+0000\n"
"POT-Creation-Date: 2017-11-07 09:32+0000\n"
"PO-Revision-Date: 2017-11-07 09:32+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
......@@ -14,3 +15,18 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: l10n_us
#: model:ir.model.fields,field_description:l10n_us.field_res_partner_bank_aba_routing
msgid "ABA/Routing"
msgstr ""
#. module: l10n_us
#: code:addons/l10n_us/models/res_partner_bank.py:16
#, python-format
msgid "ABA/Routing should only contains numbers (maximum 9 digits)."
msgstr ""
#. module: l10n_us
#: model:ir.model.fields,help:l10n_us.field_res_partner_bank_aba_routing
msgid "American Bankers Association Routing Number"
msgstr ""
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
import re
from odoo import fields, models, api, _
from odoo.exceptions import UserError
class ResPartnerBank(models.Model):
_inherit = 'res.partner.bank'
aba_routing = fields.Integer(string="ABA/Routing", help="American Bankers Association Routing Number")
def _check_aba_routing(self, aba_routing):
if aba_routing and not re.match(r'^\d{1,9}$', aba_routing):
raise UserError(_('ABA/Routing should only contains numbers (maximum 9 digits).'))
return aba_routing
# ONLY FOR v11. DO NOT FORWARDPORT!
@api.model
def create(self, vals):
if vals.get('aba_routing'):
vals['aba_routing'] = int(self._check_aba_routing(vals['aba_routing']))
return super(ResPartnerBank, self).create(vals)
@api.multi
def write(self, vals):
if vals.get('aba_routing'):
vals['aba_routing'] = int(self._check_aba_routing(vals['aba_routing']))
return super(ResPartnerBank, self).write(vals)
@api.multi
def read(self, fields=None, load='_classic_read'):
result = super(ResPartnerBank, self).read(fields, load=load)
for record in result:
if record.get('aba_routing'):
record['aba_routing'] = str(record['aba_routing'])
return result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment