[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.
Therefore we simply change the type of field and add the appropriate
contraint.

opw-781069
This commit is contained in:
Nicolas Martinelli
2017-11-07 10:52:21 +01:00
parent 0a8c5c12e5
commit a824b9121f
3 changed files with 30 additions and 6 deletions
+19 -3
View File
@@ -1,12 +1,13 @@
# 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 12.0alpha1+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:51+0000\n"
"PO-Revision-Date: 2017-11-07 09:51+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:18
#, 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 ""
+10 -2
View File
@@ -1,10 +1,18 @@
# -*- 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 ValidationError
class ResPartnerBank(models.Model):
_inherit = 'res.partner.bank'
aba_routing = fields.Integer(string="ABA/Routing", help="American Bankers Association Routing Number")
aba_routing = fields.Char(string="ABA/Routing", help="American Bankers Association Routing Number")
@api.constrains('aba_routing')
def _check_aba_routing(self):
for bank in self:
if bank.aba_routing and not re.match(r'^\d{1,9}$', bank.aba_routing):
raise ValidationError(_('ABA/Routing should only contains numbers (maximum 9 digits).'))
@@ -6,7 +6,7 @@
<field name="inherit_id" ref="base.view_partner_bank_form"/>
<field name="arch" type="xml">
<field name="bank_id" position="after">
<field name="aba_routing" widget="char"/>
<field name="aba_routing"/>
</field>
</field>
</record>