diff --git a/account_payment_mode_brand/README.rst b/account_payment_mode_brand/README.rst new file mode 100644 index 000000000..27abc698d --- /dev/null +++ b/account_payment_mode_brand/README.rst @@ -0,0 +1,100 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +========================== +Account Payment Mode Brand +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:00cb33c0ef501c88b031a81d90cc9e2b0e63a4ea2f50266638774714bc1483dd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_payment_mode_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_payment_mode_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 addon define allowed payment mode per brand. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +1. Define the brand use level (see brand module documentation) + +2. Go to Settings > Users & Companies > Brands + +3. Select a brand + +4. Define allowed payment modes + +5. Create a new invoice + + 1. Select the brand + 2. Select a payment mode + +The payment mode list is filtered with the brand allowed payment modes. + +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 +------------ + +- Souheil Bejaoui + +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_payment_mode_brand/__init__.py b/account_payment_mode_brand/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/account_payment_mode_brand/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_payment_mode_brand/__manifest__.py b/account_payment_mode_brand/__manifest__.py new file mode 100644 index 000000000..f3c8d379b --- /dev/null +++ b/account_payment_mode_brand/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Account Payment Mode Brand", + "summary": """ + This addon define allowed payment mode per 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": [ + "brand", + "account_brand", + "account_payment_mode", + "base_view_inheritance_extension", + ], + "data": [ + "views/res_brand.xml", + "views/account_move.xml", + ], +} diff --git a/account_payment_mode_brand/i18n/account_payment_mode_brand.pot b/account_payment_mode_brand/i18n/account_payment_mode_brand.pot new file mode 100644 index 000000000..e8106e28e --- /dev/null +++ b/account_payment_mode_brand/i18n/account_payment_mode_brand.pot @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_mode_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_payment_mode_brand +#: model:ir.model.fields,field_description:account_payment_mode_brand.field_account_bank_statement_line__allowed_payment_mode_ids +#: model:ir.model.fields,field_description:account_payment_mode_brand.field_account_move__allowed_payment_mode_ids +#: model:ir.model.fields,field_description:account_payment_mode_brand.field_contract_contract__allowed_payment_mode_ids +#: model:ir.model.fields,field_description:account_payment_mode_brand.field_res_brand_mixin__allowed_payment_mode_ids +msgid "Allowed Payment Mode" +msgstr "" + +#. module: account_payment_mode_brand +#: model:ir.model.fields,field_description:account_payment_mode_brand.field_res_brand__allowed_payment_mode_ids +msgid "Allowed payment modes" +msgstr "" + +#. module: account_payment_mode_brand +#: model:ir.model,name:account_payment_mode_brand.model_res_brand +msgid "Brand" +msgstr "" + +#. module: account_payment_mode_brand +#: model:ir.model,name:account_payment_mode_brand.model_res_brand_mixin +msgid "Brand Mixin" +msgstr "" diff --git a/account_payment_mode_brand/i18n/it.po b/account_payment_mode_brand/i18n/it.po new file mode 100644 index 000000000..1dbd91d09 --- /dev/null +++ b/account_payment_mode_brand/i18n/it.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_mode_brand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-07-30 14:25+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_payment_mode_brand +#: model:ir.model.fields,field_description:account_payment_mode_brand.field_account_bank_statement_line__allowed_payment_mode_ids +#: model:ir.model.fields,field_description:account_payment_mode_brand.field_account_move__allowed_payment_mode_ids +#: model:ir.model.fields,field_description:account_payment_mode_brand.field_contract_contract__allowed_payment_mode_ids +#: model:ir.model.fields,field_description:account_payment_mode_brand.field_res_brand_mixin__allowed_payment_mode_ids +msgid "Allowed Payment Mode" +msgstr "Metodo di pagamento consentito" + +#. module: account_payment_mode_brand +#: model:ir.model.fields,field_description:account_payment_mode_brand.field_res_brand__allowed_payment_mode_ids +msgid "Allowed payment modes" +msgstr "Metodi di pagamento consentiti" + +#. module: account_payment_mode_brand +#: model:ir.model,name:account_payment_mode_brand.model_res_brand +msgid "Brand" +msgstr "Marca" + +#. module: account_payment_mode_brand +#: model:ir.model,name:account_payment_mode_brand.model_res_brand_mixin +msgid "Brand Mixin" +msgstr "Mixin marca" diff --git a/account_payment_mode_brand/models/__init__.py b/account_payment_mode_brand/models/__init__.py new file mode 100644 index 000000000..e1d277e0a --- /dev/null +++ b/account_payment_mode_brand/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_brand +from . import res_brand_mixin diff --git a/account_payment_mode_brand/models/res_brand.py b/account_payment_mode_brand/models/res_brand.py new file mode 100644 index 000000000..ae702f8c6 --- /dev/null +++ b/account_payment_mode_brand/models/res_brand.py @@ -0,0 +1,12 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResBrand(models.Model): + _inherit = "res.brand" + + allowed_payment_mode_ids = fields.Many2many( + comodel_name="account.payment.mode", string="Allowed payment modes" + ) diff --git a/account_payment_mode_brand/models/res_brand_mixin.py b/account_payment_mode_brand/models/res_brand_mixin.py new file mode 100644 index 000000000..6f7e86564 --- /dev/null +++ b/account_payment_mode_brand/models/res_brand_mixin.py @@ -0,0 +1,24 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ResBrandMixin(models.AbstractModel): + _inherit = "res.brand.mixin" + + allowed_payment_mode_ids = fields.Many2many( + comodel_name="account.payment.mode", + compute="_compute_allowed_payment_mode_ids", + ) + + @api.depends("brand_id") + def _compute_allowed_payment_mode_ids(self): + all_payment_mode = self.env["account.payment.mode"].search( + [("active", "=", True)] + ) + for rec in self: + if rec.brand_id and rec.brand_id.allowed_payment_mode_ids: + rec.allowed_payment_mode_ids = rec.brand_id.allowed_payment_mode_ids + else: + rec.allowed_payment_mode_ids = all_payment_mode diff --git a/account_payment_mode_brand/pyproject.toml b/account_payment_mode_brand/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/account_payment_mode_brand/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_payment_mode_brand/readme/CONTRIBUTORS.md b/account_payment_mode_brand/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..e3c04dcc7 --- /dev/null +++ b/account_payment_mode_brand/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Souheil Bejaoui \ diff --git a/account_payment_mode_brand/readme/DESCRIPTION.md b/account_payment_mode_brand/readme/DESCRIPTION.md new file mode 100644 index 000000000..32a3a0aca --- /dev/null +++ b/account_payment_mode_brand/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This addon define allowed payment mode per brand. diff --git a/account_payment_mode_brand/readme/USAGE.md b/account_payment_mode_brand/readme/USAGE.md new file mode 100644 index 000000000..eee3e00aa --- /dev/null +++ b/account_payment_mode_brand/readme/USAGE.md @@ -0,0 +1,15 @@ +To use this module, you need to: + +1. Define the brand use level (see brand module documentation) + +2. Go to Settings \> Users & Companies \> Brands + +3. Select a brand + +4. Define allowed payment modes + +5. Create a new invoice + 1. Select the brand + 2. Select a payment mode + +The payment mode list is filtered with the brand allowed payment modes. diff --git a/account_payment_mode_brand/static/description/icon.png b/account_payment_mode_brand/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_payment_mode_brand/static/description/icon.png differ diff --git a/account_payment_mode_brand/static/description/index.html b/account_payment_mode_brand/static/description/index.html new file mode 100644 index 000000000..a60202f33 --- /dev/null +++ b/account_payment_mode_brand/static/description/index.html @@ -0,0 +1,446 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Account Payment Mode Brand

+ +

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

+

This addon define allowed payment mode per brand.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Define the brand use level (see brand module documentation)
  2. +
  3. Go to Settings > Users & Companies > Brands
  4. +
  5. Select a brand
  6. +
  7. Define allowed payment modes
  8. +
  9. Create a new invoice
      +
    1. Select the brand
    2. +
    3. Select a payment mode
    4. +
    +
  10. +
+

The payment mode list is filtered with the brand allowed payment modes.

+
+
+

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_payment_mode_brand/tests/__init__.py b/account_payment_mode_brand/tests/__init__.py new file mode 100644 index 000000000..7c517f93d --- /dev/null +++ b/account_payment_mode_brand/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_payment_mode_brand diff --git a/account_payment_mode_brand/tests/test_account_payment_mode_brand.py b/account_payment_mode_brand/tests/test_account_payment_mode_brand.py new file mode 100644 index 000000000..db22c36b2 --- /dev/null +++ b/account_payment_mode_brand/tests/test_account_payment_mode_brand.py @@ -0,0 +1,68 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestBasePaymentModeBrand(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.manual_out = cls.env.ref("account.account_payment_method_manual_out") + cls.company = cls.env.user.company_id + cls.journal_1 = cls.env["account.journal"].create( + { + "name": "J1", + "code": "J1", + "type": "bank", + "company_id": cls.company.id, + "bank_acc_number": "123456", + } + ) + cls.payment_mode_1 = cls.env["account.payment.mode"].create( + { + "name": "Customer To Bank 1", + "bank_account_link": "variable", + "payment_method_id": cls.manual_out.id, + "show_bank_account_from_journal": True, + "company_id": cls.company.id, + "fixed_journal_id": cls.journal_1.id, + "variable_journal_ids": [(6, 0, [cls.journal_1.id])], + } + ) + cls.payment_mode_2 = cls.env["account.payment.mode"].create( + { + "name": "Customer To Bank 2", + "bank_account_link": "variable", + "payment_method_id": cls.manual_out.id, + "show_bank_account_from_journal": True, + "company_id": cls.company.id, + "fixed_journal_id": cls.journal_1.id, + "variable_journal_ids": [(6, 0, [cls.journal_1.id])], + } + ) + cls.partner = cls.env["res.partner"].create( + { + "name": "Customer", + "customer_payment_mode_id": cls.payment_mode_1.id, + } + ) + cls.brand = cls.env["res.brand"].create({"name": "brand"}) + cls.brand.allowed_payment_mode_ids = cls.payment_mode_1 + + +class TestAccountPaymentModeBrand(TestBasePaymentModeBrand): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.invoice = cls.env["account.move"].create( + {"partner_id": cls.partner.id, "brand_id": cls.brand.id} + ) + + def test_account_invoice_allowed_payment_mode(self): + self.assertEqual(self.invoice.allowed_payment_mode_ids, self.payment_mode_1) + self.invoice.brand_id = False + self.assertEqual( + self.invoice.allowed_payment_mode_ids, + self.env["account.payment.mode"].search([]), + ) diff --git a/account_payment_mode_brand/views/account_move.xml b/account_payment_mode_brand/views/account_move.xml new file mode 100644 index 000000000..df5425c60 --- /dev/null +++ b/account_payment_mode_brand/views/account_move.xml @@ -0,0 +1,16 @@ + + + + + account.move + + + + + [('id', 'in', allowed_payment_mode_ids)] + + + + + diff --git a/account_payment_mode_brand/views/res_brand.xml b/account_payment_mode_brand/views/res_brand.xml new file mode 100644 index 000000000..d2b59eeec --- /dev/null +++ b/account_payment_mode_brand/views/res_brand.xml @@ -0,0 +1,20 @@ + + + + + res.brand + + + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..94529079c --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,4 @@ +odoo-addon-brand @ git+https://github.com/OCA/brand.git@refs/pull/270/head#subdirectory=brand +odoo-addon-account_brand @ git+https://github.com/OCA/brand.git@refs/pull/271/head#subdirectory=account_brand +odoo-addon-account_payment_mode @ git+https://github.com/OCA/bank-payment.git@refs/pull/1504/head#subdirectory=account_payment_mode +odoo-addon-base_view_inheritance_extension @ git+https://github.com/OCA/server-tools.git@refs/pull/3382/head#subdirectory=base_view_inheritance_extension