diff --git a/account_invoice_bank_brand/README.rst b/account_invoice_bank_brand/README.rst new file mode 100644 index 000000000..335350d9c --- /dev/null +++ b/account_invoice_bank_brand/README.rst @@ -0,0 +1,104 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +========================== +Account Invoice Bank Brand +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b06e0a7df5086664d24412deaa56546afbb59c6f1657e49549e1af20e5e04d32 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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%2Fbrand-lightgray.png?logo=github + :target: https://github.com/OCA/brand/tree/19.0/account_invoice_bank_brand + :alt: OCA/brand +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/brand-19-0/brand-19-0-account_invoice_bank_brand + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/brand&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module addresses the need to specify different receiving bank +accounts based on brand. When generating invoices, the module +automatically populates the invoice's bank account field with the +configured default, streamlining the payment process and ensuring +invoices specify the correct remittance details based on the brand. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +1. Go to Settings > Users & Companies > Brands + +2. Select a brand + +3. Define its bank account + +4. Create a new invoice + + 1. Select the brand + 2. The bank account is automatically filled with the brand's + specified bank account. + +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 to smash 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 +------------ + +- Quentin Groulard +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia + +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/brand `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_invoice_bank_brand/__init__.py b/account_invoice_bank_brand/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/account_invoice_bank_brand/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_invoice_bank_brand/__manifest__.py b/account_invoice_bank_brand/__manifest__.py new file mode 100644 index 000000000..3ebf327a0 --- /dev/null +++ b/account_invoice_bank_brand/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Account Invoice Bank Brand", + "summary": "Enables the automatic selection of the partner's" + "bank account on invoices based on the brand.", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/brand", + "depends": ["account_brand"], + "data": ["views/res_brand.xml"], +} diff --git a/account_invoice_bank_brand/i18n/account_invoice_bank_brand.pot b/account_invoice_bank_brand/i18n/account_invoice_bank_brand.pot new file mode 100644 index 000000000..51877b852 --- /dev/null +++ b/account_invoice_bank_brand/i18n/account_invoice_bank_brand.pot @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_bank_brand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: account_invoice_bank_brand +#: model:ir.model.fields,field_description:account_invoice_bank_brand.field_res_brand__partner_bank_id +msgid "Bank Account" +msgstr "" + +#. module: account_invoice_bank_brand +#: model:ir.model.fields,help:account_invoice_bank_brand.field_res_brand__partner_bank_id +msgid "" +"Bank Account Number to which the invoices of this brand will be paid (for " +"Customer Invoice and Vendor Credit Note)" +msgstr "" + +#. module: account_invoice_bank_brand +#: model:ir.model,name:account_invoice_bank_brand.model_res_brand +msgid "Brand" +msgstr "" + +#. module: account_invoice_bank_brand +#: model_terms:ir.ui.view,arch_db:account_invoice_bank_brand.res_brand_form_view +msgid "Invoices" +msgstr "" + +#. module: account_invoice_bank_brand +#: model:ir.model,name:account_invoice_bank_brand.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_invoice_bank_brand +#. odoo-python +#: code:addons/account_invoice_bank_brand/models/res_brand.py:0 +msgid "" +"The account selected for invoices payment does not belong to the same " +"partner as this brand." +msgstr "" diff --git a/account_invoice_bank_brand/i18n/it.po b/account_invoice_bank_brand/i18n/it.po new file mode 100644 index 000000000..65e3c2ae4 --- /dev/null +++ b/account_invoice_bank_brand/i18n/it.po @@ -0,0 +1,56 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_bank_brand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-07-30 12:05+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.10.4\n" + +#. module: account_invoice_bank_brand +#: model:ir.model.fields,field_description:account_invoice_bank_brand.field_res_brand__partner_bank_id +msgid "Bank Account" +msgstr "Conto bancario" + +#. module: account_invoice_bank_brand +#: model:ir.model.fields,help:account_invoice_bank_brand.field_res_brand__partner_bank_id +msgid "" +"Bank Account Number to which the invoices of this brand will be paid (for " +"Customer Invoice and Vendor Credit Note)" +msgstr "" +"Numero del conto bancario su cui verranno pagate le fatture di questa marca (" +"per fattura cliente e note di credito fornitore)" + +#. module: account_invoice_bank_brand +#: model:ir.model,name:account_invoice_bank_brand.model_res_brand +msgid "Brand" +msgstr "Marca" + +#. module: account_invoice_bank_brand +#: model_terms:ir.ui.view,arch_db:account_invoice_bank_brand.res_brand_form_view +msgid "Invoices" +msgstr "Fatture" + +#. module: account_invoice_bank_brand +#: model:ir.model,name:account_invoice_bank_brand.model_account_move +msgid "Journal Entry" +msgstr "Registrazione contabile" + +#. module: account_invoice_bank_brand +#. odoo-python +#: code:addons/account_invoice_bank_brand/models/res_brand.py:0 +msgid "" +"The account selected for invoices payment does not belong to the same " +"partner as this brand." +msgstr "" +"Il conto selezionato per il pagamento delle fatture non appartiene allo " +"stesso partner della marca." diff --git a/account_invoice_bank_brand/i18n/nl.po b/account_invoice_bank_brand/i18n/nl.po new file mode 100644 index 000000000..5d91b86e5 --- /dev/null +++ b/account_invoice_bank_brand/i18n/nl.po @@ -0,0 +1,56 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_bank_brand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-08-09 15:25+0000\n" +"Last-Translator: Bosd \n" +"Language-Team: none\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.10.4\n" + +#. module: account_invoice_bank_brand +#: model:ir.model.fields,field_description:account_invoice_bank_brand.field_res_brand__partner_bank_id +msgid "Bank Account" +msgstr "Bankrekening" + +#. module: account_invoice_bank_brand +#: model:ir.model.fields,help:account_invoice_bank_brand.field_res_brand__partner_bank_id +msgid "" +"Bank Account Number to which the invoices of this brand will be paid (for " +"Customer Invoice and Vendor Credit Note)" +msgstr "" +"Bankrekeningnummer waarop de facturen van dit merk betaald zullen worden (" +"voor Klantfactuur en Leverancierscreditnota)" + +#. module: account_invoice_bank_brand +#: model:ir.model,name:account_invoice_bank_brand.model_res_brand +msgid "Brand" +msgstr "Merk" + +#. module: account_invoice_bank_brand +#: model_terms:ir.ui.view,arch_db:account_invoice_bank_brand.res_brand_form_view +msgid "Invoices" +msgstr "Facturen" + +#. module: account_invoice_bank_brand +#: model:ir.model,name:account_invoice_bank_brand.model_account_move +msgid "Journal Entry" +msgstr "Journaalpost" + +#. module: account_invoice_bank_brand +#. odoo-python +#: code:addons/account_invoice_bank_brand/models/res_brand.py:0 +msgid "" +"The account selected for invoices payment does not belong to the same " +"partner as this brand." +msgstr "" +"De geselecteerde rekening voor factuurbetaling behoort niet toe aan dezelfde " +"partner als dit merk." diff --git a/account_invoice_bank_brand/models/__init__.py b/account_invoice_bank_brand/models/__init__.py new file mode 100644 index 000000000..87d463b98 --- /dev/null +++ b/account_invoice_bank_brand/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_move +from . import res_brand diff --git a/account_invoice_bank_brand/models/account_move.py b/account_invoice_bank_brand/models/account_move.py new file mode 100644 index 000000000..faf2894d5 --- /dev/null +++ b/account_invoice_bank_brand/models/account_move.py @@ -0,0 +1,20 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + @api.depends("brand_id") + def _compute_partner_bank_id(self): + res = super()._compute_partner_bank_id() + for move in self: + if ( + move.move_type in ("out_invoice", "in_refund") + and move.brand_id + and move.brand_id.partner_bank_id + ): + move.partner_bank_id = move.brand_id.partner_bank_id + return res diff --git a/account_invoice_bank_brand/models/res_brand.py b/account_invoice_bank_brand/models/res_brand.py new file mode 100644 index 000000000..6699dbbbd --- /dev/null +++ b/account_invoice_bank_brand/models/res_brand.py @@ -0,0 +1,31 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models +from odoo.exceptions import ValidationError + + +class ResBrand(models.Model): + _inherit = "res.brand" + + partner_bank_id = fields.Many2one( + comodel_name="res.partner.bank", + domain="[('partner_id', '=', partner_id)]", + string="Bank Account", + help="Bank Account Number to which the invoices of this " + "brand will be paid (for Customer Invoice and Vendor Credit Note)", + ) + + @api.constrains("partner_id", "partner_bank_id") + def validate_partner_bank_id(self): + for record in self: + if ( + record.partner_bank_id + and record.partner_id != record.partner_bank_id.partner_id + ): + raise ValidationError( + self.env._( + "The account selected for invoices payment does not " + "belong to the same partner as this brand." + ) + ) diff --git a/account_invoice_bank_brand/pyproject.toml b/account_invoice_bank_brand/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/account_invoice_bank_brand/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_invoice_bank_brand/readme/CONTRIBUTORS.md b/account_invoice_bank_brand/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..02d7c14f8 --- /dev/null +++ b/account_invoice_bank_brand/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Quentin Groulard \<\> +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia diff --git a/account_invoice_bank_brand/readme/DESCRIPTION.md b/account_invoice_bank_brand/readme/DESCRIPTION.md new file mode 100644 index 000000000..3451e97e9 --- /dev/null +++ b/account_invoice_bank_brand/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module addresses the need to specify different receiving bank accounts based on brand. +When generating invoices, the module automatically populates the invoice's bank account field with the configured default, streamlining the payment process and ensuring invoices specify the correct remittance details based on the brand. diff --git a/account_invoice_bank_brand/readme/USAGE.md b/account_invoice_bank_brand/readme/USAGE.md new file mode 100644 index 000000000..5cf1c4ed7 --- /dev/null +++ b/account_invoice_bank_brand/readme/USAGE.md @@ -0,0 +1,11 @@ +To use this module, you need to: + +1. Go to Settings \> Users & Companies \> Brands + +2. Select a brand + +3. Define its bank account + +4. Create a new invoice + 1. Select the brand + 2. The bank account is automatically filled with the brand's specified bank account. diff --git a/account_invoice_bank_brand/static/description/icon.png b/account_invoice_bank_brand/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_invoice_bank_brand/static/description/icon.png differ diff --git a/account_invoice_bank_brand/static/description/index.html b/account_invoice_bank_brand/static/description/index.html new file mode 100644 index 000000000..71cdb82d2 --- /dev/null +++ b/account_invoice_bank_brand/static/description/index.html @@ -0,0 +1,453 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Account Invoice Bank Brand

+ +

Beta License: AGPL-3 OCA/brand Translate me on Weblate Try me on Runboat

+

This module addresses the need to specify different receiving bank +accounts based on brand. When generating invoices, the module +automatically populates the invoice’s bank account field with the +configured default, streamlining the payment process and ensuring +invoices specify the correct remittance details based on the brand.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Settings > Users & Companies > Brands
  2. +
  3. Select a brand
  4. +
  5. Define its bank account
  6. +
  7. Create a new invoice
      +
    1. Select the brand
    2. +
    3. The bank account is automatically filled with the brand’s +specified bank account.
    4. +
    +
  8. +
+
+
+

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 to smash 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/brand project on GitHub.

+

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

+
+
+
+
+ + diff --git a/account_invoice_bank_brand/tests/__init__.py b/account_invoice_bank_brand/tests/__init__.py new file mode 100644 index 000000000..f15da2000 --- /dev/null +++ b/account_invoice_bank_brand/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_move diff --git a/account_invoice_bank_brand/tests/test_account_move.py b/account_invoice_bank_brand/tests/test_account_move.py new file mode 100644 index 000000000..1391c5558 --- /dev/null +++ b/account_invoice_bank_brand/tests/test_account_move.py @@ -0,0 +1,83 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.exceptions import ValidationError + +from odoo.addons.base.tests.common import BaseCommon + + +class TestAccountInvoiceBankBrand(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.company = cls.env.ref("base.main_company") + cls.journal = cls.env["account.journal"].create( + { + "name": "Sale Journal", + "code": "SALE", + "type": "sale", + "company_id": cls.company.id, + } + ) + cls.invoice = cls.env["account.move"].create( + { + "partner_id": cls.partner.id, + "move_type": "out_invoice", + "company_id": cls.company.id, + "partner_bank_id": False, # Explicitly set to False + } + ) + cls.partner_bank = cls.env["res.partner.bank"].create( + { + "partner_id": cls.partner.id, + "acc_number": "NL1234567890", + "company_id": cls.company.id, + } + ) + cls.brand = cls.env["res.brand"].create( + { + "name": "Test Brand", + "partner_id": cls.partner.id, + "company_id": cls.company.id, + } + ) + + def test_brand_compute_partner_bank_id(self): + # 1. Set brand_id on invoice + self.invoice.brand_id = self.brand + # 2. Assert partner_bank_id is set if brand has it + self.brand.partner_bank_id = self.partner_bank + # Trigger recompute + self.invoice._compute_partner_bank_id() + self.assertEqual(self.invoice.partner_bank_id, self.brand.partner_bank_id) + + def test_create_invoice_with_brand(self): + self.brand.partner_bank_id = self.partner_bank + invoice = self.env["account.move"].create( + { + "partner_id": self.partner.id, + "move_type": "out_invoice", + "brand_id": self.brand.id, + "company_id": self.company.id, + } + ) + self.assertEqual(invoice.partner_bank_id, self.brand.partner_bank_id) + + def test_validate_partner_bank_id_constraint(self): + # 1. Create a bank account for a different partner + another_partner = self.env["res.partner"].create({"name": "Another Partner"}) + another_partner_bank = self.env["res.partner.bank"].create( + { + "partner_id": another_partner.id, + "acc_number": "OTHER123", + "company_id": self.company.id, + } + ) + + # 2. Expect a ValidationError when assigning the invalid bank account + with self.assertRaises(ValidationError): + self.brand.partner_bank_id = another_partner_bank + + # 3. Assign a valid bank account (this should work) + self.brand.partner_bank_id = self.partner_bank + self.brand.validate_partner_bank_id() diff --git a/account_invoice_bank_brand/views/res_brand.xml b/account_invoice_bank_brand/views/res_brand.xml new file mode 100644 index 000000000..5a3f46f0a --- /dev/null +++ b/account_invoice_bank_brand/views/res_brand.xml @@ -0,0 +1,17 @@ + + + + + res.brand.form (in account_invoice_bank_brand) + res.brand + + + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..2616819c2 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-account_brand @ git+https://github.com/OCA/brand.git@refs/pull/303/head#subdirectory=account_brand