diff --git a/agreement_rebate_partner_company_group/README.rst b/agreement_rebate_partner_company_group/README.rst new file mode 100644 index 0000000000..1aced2eecc --- /dev/null +++ b/agreement_rebate_partner_company_group/README.rst @@ -0,0 +1,96 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +====================================== +Agreement Rebate Partner Company Group +====================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:f3e97d58253f03b1da7857a63526e03fa23597ffe1798156f871ddd5a3c0b653 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fcontract-lightgray.png?logo=github + :target: https://github.com/OCA/contract/tree/19.0/agreement_rebate_partner_company_group + :alt: OCA/contract +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/contract-19-0/contract-19-0-agreement_rebate_partner_company_group + :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/contract&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of agreement module to take into +account if agreements affect to all company group members. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module you need to: + +1. Create an agreement related with a company group partner. +2. Create several invoices related with company group members. +3. Create rebate settlements from *Agreements > Settlements > Create + Settlements* wizard + +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 +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Carlos Dauden + - Sergio Teruel + - Ernesto Tejeda + - Stefan Ungureanu + +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/contract `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/agreement_rebate_partner_company_group/__init__.py b/agreement_rebate_partner_company_group/__init__.py new file mode 100644 index 0000000000..8965bbe525 --- /dev/null +++ b/agreement_rebate_partner_company_group/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import wizards diff --git a/agreement_rebate_partner_company_group/__manifest__.py b/agreement_rebate_partner_company_group/__manifest__.py new file mode 100644 index 0000000000..ee56a4909a --- /dev/null +++ b/agreement_rebate_partner_company_group/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2022 Tecnativa - Carlos Dauden +# Copyright 2022 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Agreement Rebate Partner Company Group", + "summary": "Rebate agreements applied to all company group members", + "version": "19.0.1.0.0", + "development_status": "Beta", + "category": "Contract", + "website": "https://github.com/OCA/contract", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["agreement_rebate", "base_partner_company_group"], +} diff --git a/agreement_rebate_partner_company_group/i18n/agreement_rebate_partner_company_group.pot b/agreement_rebate_partner_company_group/i18n/agreement_rebate_partner_company_group.pot new file mode 100644 index 0000000000..b89adbbb56 --- /dev/null +++ b/agreement_rebate_partner_company_group/i18n/agreement_rebate_partner_company_group.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * agreement_rebate_partner_company_group +# +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: agreement_rebate_partner_company_group +#: model:ir.model,name:agreement_rebate_partner_company_group.model_agreement_settlement_create_wiz +msgid "Agreement settlement create wizard" +msgstr "" diff --git a/agreement_rebate_partner_company_group/i18n/fr.po b/agreement_rebate_partner_company_group/i18n/fr.po new file mode 100644 index 0000000000..43095b75df --- /dev/null +++ b/agreement_rebate_partner_company_group/i18n/fr.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * agreement_rebate_partner_company_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-01-04 08:42+0000\n" +"Last-Translator: Quentin THEURET \n" +"Language-Team: none\n" +"Language: fr\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: agreement_rebate_partner_company_group +#: model:ir.model,name:agreement_rebate_partner_company_group.model_agreement_settlement_create_wiz +msgid "Agreement settlement create wizard" +msgstr "Assistant de création d'accord de règlement" diff --git a/agreement_rebate_partner_company_group/i18n/it.po b/agreement_rebate_partner_company_group/i18n/it.po new file mode 100644 index 0000000000..b52529c2d7 --- /dev/null +++ b/agreement_rebate_partner_company_group/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * agreement_rebate_partner_company_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-05-06 12:38+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 4.17\n" + +#. module: agreement_rebate_partner_company_group +#: model:ir.model,name:agreement_rebate_partner_company_group.model_agreement_settlement_create_wiz +msgid "Agreement settlement create wizard" +msgstr "Procedura guidata creazione regolazione accordo" diff --git a/agreement_rebate_partner_company_group/pyproject.toml b/agreement_rebate_partner_company_group/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/agreement_rebate_partner_company_group/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/agreement_rebate_partner_company_group/readme/CONTRIBUTORS.md b/agreement_rebate_partner_company_group/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..afc60dfd15 --- /dev/null +++ b/agreement_rebate_partner_company_group/readme/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +- [Tecnativa](https://www.tecnativa.com): + + > - Carlos Dauden + > - Sergio Teruel + > - Ernesto Tejeda + > - Stefan Ungureanu diff --git a/agreement_rebate_partner_company_group/readme/DESCRIPTION.md b/agreement_rebate_partner_company_group/readme/DESCRIPTION.md new file mode 100644 index 0000000000..046cf36c7a --- /dev/null +++ b/agreement_rebate_partner_company_group/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends the functionality of agreement module to take into +account if agreements affect to all company group members. diff --git a/agreement_rebate_partner_company_group/readme/USAGE.md b/agreement_rebate_partner_company_group/readme/USAGE.md new file mode 100644 index 0000000000..6245bf414c --- /dev/null +++ b/agreement_rebate_partner_company_group/readme/USAGE.md @@ -0,0 +1,6 @@ +To use this module you need to: + +1. Create an agreement related with a company group partner. +2. Create several invoices related with company group members. +3. Create rebate settlements from *Agreements \> Settlements \> Create + Settlements* wizard diff --git a/agreement_rebate_partner_company_group/static/description/icon.png b/agreement_rebate_partner_company_group/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/agreement_rebate_partner_company_group/static/description/icon.png differ diff --git a/agreement_rebate_partner_company_group/static/description/index.html b/agreement_rebate_partner_company_group/static/description/index.html new file mode 100644 index 0000000000..b1aef8c844 --- /dev/null +++ b/agreement_rebate_partner_company_group/static/description/index.html @@ -0,0 +1,450 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Agreement Rebate Partner Company Group

+ +

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

+

This module extends the functionality of agreement module to take into +account if agreements affect to all company group members.

+

Table of contents

+ +
+

Usage

+

To use this module you need to:

+
    +
  1. Create an agreement related with a company group partner.
  2. +
  3. Create several invoices related with company group members.
  4. +
  5. Create rebate settlements from Agreements > Settlements > Create +Settlements wizard
  6. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:

    +
    +
      +
    • Carlos Dauden
    • +
    • Sergio Teruel
    • +
    • Ernesto Tejeda
    • +
    • Stefan Ungureanu
    • +
    +
    +
  • +
+
+
+

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

+

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

+
+
+
+
+ + diff --git a/agreement_rebate_partner_company_group/tests/__init__.py b/agreement_rebate_partner_company_group/tests/__init__.py new file mode 100644 index 0000000000..ffd17a4bc0 --- /dev/null +++ b/agreement_rebate_partner_company_group/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_agreement_rebate diff --git a/agreement_rebate_partner_company_group/tests/test_agreement_rebate.py b/agreement_rebate_partner_company_group/tests/test_agreement_rebate.py new file mode 100644 index 0000000000..003887c25d --- /dev/null +++ b/agreement_rebate_partner_company_group/tests/test_agreement_rebate.py @@ -0,0 +1,37 @@ +# Copyright 2022 Tecnativa - Carlos Dauden +# Copyright 2025 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests import tagged + +from odoo.addons.agreement_rebate.tests.test_agreement_rebate import ( + TestAgreementRebateBase, +) + + +@tagged("-at_install", "post_install") +class TestAgreementRebatePartnerCompanyGroup(TestAgreementRebateBase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner_group = cls.env["res.partner"].create( + {"name": "partner test rebate group", "ref": "TST-G01"} + ) + cls.partner_1.company_group_id = cls.partner_group + cls.partner_2.company_group_id = cls.partner_group + + def test_create_settlement_wo_filters_global_company_group(self): + """Global rebate without filters apply to all company group members""" + # Total by invoice: 3800 amount invoiced + # 2 invoice members: 3800 * 2 = 7600 + + # Global rebate without filters + agreement_global = self.create_agreements_rebate("global", self.partner_group) + agreement_global.rebate_line_ids = False + settlement_wiz = self.create_settlement_wizard(agreement_global) + settlements = self.get_settlements_from_action( + settlement_wiz.action_create_settlement() + ) + self.assertEqual(len(settlements), 1) + self.assertEqual(settlements.amount_invoiced, 7600) + self.assertEqual(settlements.amount_rebate, 760) diff --git a/agreement_rebate_partner_company_group/wizards/__init__.py b/agreement_rebate_partner_company_group/wizards/__init__.py new file mode 100644 index 0000000000..1c180188ed --- /dev/null +++ b/agreement_rebate_partner_company_group/wizards/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import settlement_create diff --git a/agreement_rebate_partner_company_group/wizards/settlement_create.py b/agreement_rebate_partner_company_group/wizards/settlement_create.py new file mode 100644 index 0000000000..e12f892b95 --- /dev/null +++ b/agreement_rebate_partner_company_group/wizards/settlement_create.py @@ -0,0 +1,23 @@ +# Copyright 2022 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class AgreementSettlementCreateWiz(models.TransientModel): + _inherit = "agreement.settlement.create.wiz" + + def _partner_domain(self, agreement): + if not agreement.partner_id.company_group_member_ids: + return super()._partner_domain(agreement) + # Try replace only child_of part in original domain + orig_domain = ("partner_id", "child_of", agreement.partner_id.ids) + domain = super()._partner_domain(agreement) + pos = 0 + if orig_domain in domain: + pos = domain.index(orig_domain) + domain.remove(orig_domain) + domain.insert( + pos, ("partner_id", "in", agreement.partner_id.company_group_member_ids.ids) + ) + return domain diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000000..cb2467585a --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +odoo-addon-agreement @ git+https://github.com/OCA/agreement.git@refs/pull/99/head#subdirectory=agreement +odoo-addon-agreement_rebate @ git+https://github.com/OCA/agreement.git@refs/pull/108/head#subdirectory=agreement_rebate