diff --git a/partner_bank_sort_code/README.rst b/partner_bank_sort_code/README.rst new file mode 100644 index 000000000..b967d2187 --- /dev/null +++ b/partner_bank_sort_code/README.rst @@ -0,0 +1,92 @@ +====================== +Partner Bank Sort Code +====================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fpartner--contact-lightgray.png?logo=github + :target: https://github.com/OCA/partner-contact/tree/10.0/partner_bank_sort_code + :alt: OCA/partner-contact +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/partner-contact-10-0/partner-contact-10-0-partner_bank_sort_code + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/134/10.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a field 'Sort Code' on Banks. + +https://en.wikipedia.org/wiki/Sort_code + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Go to a Partner Form, Payments section and click on 'x Bank account(s)' + +On each bank account, go to the bank field. + +For that bank, fill in the Sort Code. It has to be unique for all active banks. + +Changelog +========= + +10.0.1.0.0 (2019-02-18) +~~~~~~~~~~~~~~~~~~~~~~~ + +* First version + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Denis Roussel + +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/partner-contact `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_bank_sort_code/__init__.py b/partner_bank_sort_code/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/partner_bank_sort_code/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_bank_sort_code/__manifest__.py b/partner_bank_sort_code/__manifest__.py new file mode 100644 index 000000000..878edb3c2 --- /dev/null +++ b/partner_bank_sort_code/__manifest__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Partner Bank Sort Code', + 'summary': """ + Adds a field in banks to manage Sort Codes""", + 'version': '10.0.1.0.0', + 'development_status': 'Beta', + 'maintainers': ['rousseldenis'], + 'license': 'AGPL-3', + 'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/partner-contact', + 'depends': [ + 'base', + ], + 'data': [ + 'views/res_bank.xml', + ], +} diff --git a/partner_bank_sort_code/models/__init__.py b/partner_bank_sort_code/models/__init__.py new file mode 100644 index 000000000..6c600d3f7 --- /dev/null +++ b/partner_bank_sort_code/models/__init__.py @@ -0,0 +1 @@ +from . import res_bank diff --git a/partner_bank_sort_code/models/res_bank.py b/partner_bank_sort_code/models/res_bank.py new file mode 100644 index 000000000..0a93ff4f8 --- /dev/null +++ b/partner_bank_sort_code/models/res_bank.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResBank(models.Model): + + _inherit = 'res.bank' + + sort_code = fields.Char() + + _sql_constraints = [( + "sort_code_unique", + "EXCLUDE (sort_code WITH =) WHERE (active = True)", + "Sort Code has to be unique"), + ] diff --git a/partner_bank_sort_code/readme/CONTRIBUTORS.rst b/partner_bank_sort_code/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9179ee4b8 --- /dev/null +++ b/partner_bank_sort_code/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Denis Roussel diff --git a/partner_bank_sort_code/readme/DESCRIPTION.rst b/partner_bank_sort_code/readme/DESCRIPTION.rst new file mode 100644 index 000000000..7bd14725c --- /dev/null +++ b/partner_bank_sort_code/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module adds a field 'Sort Code' on Banks. + +https://en.wikipedia.org/wiki/Sort_code diff --git a/partner_bank_sort_code/readme/HISTORY.rst b/partner_bank_sort_code/readme/HISTORY.rst new file mode 100644 index 000000000..1531aaebc --- /dev/null +++ b/partner_bank_sort_code/readme/HISTORY.rst @@ -0,0 +1,4 @@ +10.0.1.0.0 (2019-02-18) +~~~~~~~~~~~~~~~~~~~~~~~ + +* First version diff --git a/partner_bank_sort_code/readme/USAGE.rst b/partner_bank_sort_code/readme/USAGE.rst new file mode 100644 index 000000000..7352fdbc0 --- /dev/null +++ b/partner_bank_sort_code/readme/USAGE.rst @@ -0,0 +1,5 @@ +Go to a Partner Form, Payments section and click on 'x Bank account(s)' + +On each bank account, go to the bank field. + +For that bank, fill in the Sort Code. It has to be unique for all active banks. diff --git a/partner_bank_sort_code/static/description/icon.png b/partner_bank_sort_code/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/partner_bank_sort_code/static/description/icon.png differ diff --git a/partner_bank_sort_code/static/description/index.html b/partner_bank_sort_code/static/description/index.html new file mode 100644 index 000000000..7f1cfd9b2 --- /dev/null +++ b/partner_bank_sort_code/static/description/index.html @@ -0,0 +1,440 @@ + + + + + + +Partner Bank Sort Code + + + +
+

Partner Bank Sort Code

+ + +

Beta License: AGPL-3 OCA/partner-contact Translate me on Weblate Try me on Runbot

+

This module adds a field ‘Sort Code’ on Banks.

+

https://en.wikipedia.org/wiki/Sort_code

+

Table of contents

+ +
+

Usage

+

Go to a Partner Form, Payments section and click on ‘x Bank account(s)’

+

On each bank account, go to the bank field.

+

For that bank, fill in the Sort Code. It has to be unique for all active banks.

+
+
+

Changelog

+
+

10.0.1.0.0 (2019-02-18)

+
    +
  • First version
  • +
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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/partner-contact project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/partner_bank_sort_code/tests/__init__.py b/partner_bank_sort_code/tests/__init__.py new file mode 100644 index 000000000..fbe93ce35 --- /dev/null +++ b/partner_bank_sort_code/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sort_code diff --git a/partner_bank_sort_code/tests/test_sort_code.py b/partner_bank_sort_code/tests/test_sort_code.py new file mode 100644 index 000000000..d677c559f --- /dev/null +++ b/partner_bank_sort_code/tests/test_sort_code.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import common +from psycopg2 import IntegrityError + + +class TestSortCode(common.TransactionCase): + + def setUp(self): + super(TestSortCode, self).setUp() + # Create two different active bank with different sort codes + + self.bank_obj = self.env['res.bank'] + + vals = { + 'name': 'BANK 1', + 'sort_code': '95-01-32', + } + self.bank_1 = self.bank_obj.create(vals) + + vals = { + 'name': 'BANK 2', + 'sort_code': '95-01-33', + } + self.bank_2 = self.bank_obj.create(vals) + + def test_sort_code_duplicate(self): + # Create a duplicate + vals = { + 'name': 'BANK 3', + 'sort_code': '95-01-32', + } + with self.assertRaises(IntegrityError): + self.bank_obj.create(vals) + + def test_sort_code(self): + # Create a new bank with new sort code + vals = { + 'name': 'BANK 3', + 'sort_code': '95-01-34', + } + self.bank_obj.create(vals) + + def test_sort_code_inactive(self): + # Set several banks with same sort code to inactive and then create + # a bank with that sort code + self.bank_1.write({'active': False}) + vals = { + 'name': 'BANK 3', + 'sort_code': '95-01-32', + } + self.bank_3 = self.bank_obj.create(vals) + self.bank_3.active = False + + vals = { + 'name': 'BANK 4', + 'sort_code': '95-01-32', + } + self.bank_obj.create(vals) diff --git a/partner_bank_sort_code/views/res_bank.xml b/partner_bank_sort_code/views/res_bank.xml new file mode 100644 index 000000000..e81b9bc64 --- /dev/null +++ b/partner_bank_sort_code/views/res_bank.xml @@ -0,0 +1,29 @@ + + + + + + + res.bank.form (in partner_bank_sort_code) + res.bank + + + + + + + + + + res.bank.tree (in partner_bank_sort_code) + res.bank + + + + + + + + + diff --git a/setup/partner_bank_sort_code/odoo/__init__.py b/setup/partner_bank_sort_code/odoo/__init__.py new file mode 100644 index 000000000..de40ea7ca --- /dev/null +++ b/setup/partner_bank_sort_code/odoo/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/partner_bank_sort_code/odoo/addons/__init__.py b/setup/partner_bank_sort_code/odoo/addons/__init__.py new file mode 100644 index 000000000..de40ea7ca --- /dev/null +++ b/setup/partner_bank_sort_code/odoo/addons/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/partner_bank_sort_code/odoo/addons/partner_bank_sort_code b/setup/partner_bank_sort_code/odoo/addons/partner_bank_sort_code new file mode 120000 index 000000000..c164d1923 --- /dev/null +++ b/setup/partner_bank_sort_code/odoo/addons/partner_bank_sort_code @@ -0,0 +1 @@ +../../../../partner_bank_sort_code/ \ No newline at end of file diff --git a/setup/partner_bank_sort_code/setup.py b/setup/partner_bank_sort_code/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/partner_bank_sort_code/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)