Skip to content

Commit

Permalink
Merge PR #72 into 13.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Oct 21, 2019
2 parents b0af705 + 3cd5eb4 commit 10769f5
Show file tree
Hide file tree
Showing 17 changed files with 769 additions and 0 deletions.
98 changes: 98 additions & 0 deletions base_bank_from_iban/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
==============
Bank from IBAN
==============

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcommunity--data--files-lightgray.png?logo=github
:target: https://github.com/OCA/community-data-files/tree/12.0/base_bank_from_iban
:alt: OCA/community-data-files
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/community-data-files-12-0/community-data-files-12-0-base_bank_from_iban
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/101/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds a code to bank definition for using it as matching for filling the bank
from the IBAN bank account number. It uses the existing by country bank mapping in
standard Odoo (https://github.com/odoo/odoo/blob/12b15cb55414d1f6dfc6b3b4e0c38638551ee54d/addons/base_iban/models/res_partner_bank.py#L81-L149),
taken from ISO 3166-1 -> IBAN template, as described here:
http://en.wikipedia.org/wiki/International_Bank_Account_Number#IBAN_formats_by_country

**Table of contents**

.. contents::
:local:

Configuration
=============

#. Go to *Contacts > Configuration > Bank Accounts > Banks*.
#. Create or modify a bank.
#. Put the corresponding code for that bank in the field "Code".

Usage
=====

To use this module, you need to:

#. Go to Partner
#. Click *Bank Account(s)* in "Sales & Purchases" page.
#. Create/modify IBAN bank account.
#. When you put the bank account number, module extracts bank digits from the format of the country, and try to match an existing bank by country and code.
#. If there's a match, the bank is selected automatically.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/community-data-files/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/community-data-files/issues/new?body=module:%20base_bank_from_iban%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`__:

* Carlos Dauden <carlos.dauden@tecnativa.com>
* Pedro M. Baeza

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/community-data-files <https://github.com/OCA/community-data-files/tree/12.0/base_bank_from_iban>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions base_bank_from_iban/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html

from . import models
15 changes: 15 additions & 0 deletions base_bank_from_iban/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2017 Tecnativa - Carlos Dauden <carlos.dauden@tecnativa.com>
# Copyright 2018 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3).

{
"name": "Bank from IBAN",
"version": "13.0.1.0.0",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/community-data-files",
"category": "Localization",
"license": "AGPL-3",
"depends": ["base_iban"],
"data": ["views/res_bank_view.xml"],
"installable": True,
}
35 changes: 35 additions & 0 deletions base_bank_from_iban/i18n/base_bank_from_iban.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_bank_from_iban
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: base_bank_from_iban
#: model:ir.model,name:base_bank_from_iban.model_res_bank
msgid "Bank"
msgstr ""

#. module: base_bank_from_iban
#: model:ir.model,name:base_bank_from_iban.model_res_partner_bank
msgid "Bank Accounts"
msgstr ""

#. module: base_bank_from_iban
#: model:ir.model.fields,field_description:base_bank_from_iban.field_res_bank__code
msgid "Code"
msgstr ""

#. module: base_bank_from_iban
#: model:ir.model,name:base_bank_from_iban.model_account_journal
msgid "Journal"
msgstr ""

5 changes: 5 additions & 0 deletions base_bank_from_iban/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3).

from . import account_journal
from . import res_bank
from . import res_partner_bank
23 changes: 23 additions & 0 deletions base_bank_from_iban/models/account_journal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2017 Tecnativa - Carlos Dauden <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3).

from odoo import api, models


class AccountJournal(models.Model):
_inherit = "account.journal"

@api.onchange("bank_acc_number")
def _onchange_bank_acc_number_base_bank_from_iban(self):
if not self.bank_acc_number:
return
partner_bank = self.env["res.partner.bank"].new(
{"acc_number": self.bank_acc_number}
)
partner_bank._onchange_acc_number_base_bank_from_iban()
self.update(
{
"bank_acc_number": partner_bank.acc_number,
"bank_id": partner_bank.bank_id.id,
}
)
10 changes: 10 additions & 0 deletions base_bank_from_iban/models/res_bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2017 Tecnativa - Carlos Dauden <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3).

from odoo import fields, models


class ResBank(models.Model):
_inherit = "res.bank"

code = fields.Char()
30 changes: 30 additions & 0 deletions base_bank_from_iban/models/res_partner_bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2017 Tecnativa - Carlos Dauden <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3).

from odoo import api, models

from odoo.addons.base_iban.models.res_partner_bank import (
_map_iban_template,
normalize_iban,
pretty_iban,
)


class ResPartnerBank(models.Model):
_inherit = "res.partner.bank"

@api.onchange("acc_number", "acc_type")
def _onchange_acc_number_base_bank_from_iban(self):
if self.acc_type != "iban":
return
acc_number = pretty_iban(normalize_iban(self.acc_number)).upper()
country_code = self.acc_number[:2].lower()
iban_template = _map_iban_template[country_code]
first_match = iban_template[2:].find("B") + 2
last_match = iban_template.rfind("B") + 1
bank_code = acc_number[first_match:last_match].replace(" ", "")
bank = self.env["res.bank"].search(
[("code", "=", bank_code), ("country.code", "=", country_code.upper())],
limit=1,
)
self.update({"bank_id": bank.id, "acc_number": acc_number})
3 changes: 3 additions & 0 deletions base_bank_from_iban/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#. Go to *Contacts > Configuration > Bank Accounts > Banks*.
#. Create or modify a bank.
#. Put the corresponding code for that bank in the field "Code".
4 changes: 4 additions & 0 deletions base_bank_from_iban/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`__:

* Carlos Dauden <carlos.dauden@tecnativa.com>
* Pedro M. Baeza
5 changes: 5 additions & 0 deletions base_bank_from_iban/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module adds a code to bank definition for using it as matching for filling the bank
from the IBAN bank account number. It uses the existing by country bank mapping in
standard Odoo (https://github.com/odoo/odoo/blob/12b15cb55414d1f6dfc6b3b4e0c38638551ee54d/addons/base_iban/models/res_partner_bank.py#L81-L149),
taken from ISO 3166-1 -> IBAN template, as described here:
http://en.wikipedia.org/wiki/International_Bank_Account_Number#IBAN_formats_by_country
7 changes: 7 additions & 0 deletions base_bank_from_iban/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To use this module, you need to:

#. Go to Partner
#. Click *Bank Account(s)* in "Sales & Purchases" page.
#. Create/modify IBAN bank account.
#. When you put the bank account number, module extracts bank digits from the format of the country, and try to match an existing bank by country and code.
#. If there's a match, the bank is selected automatically.
Binary file added base_bank_from_iban/static/description/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 10769f5

Please sign in to comment.