diff --git a/partner_inherit_company/README.rst b/partner_inherit_company/README.rst new file mode 100644 index 00000000000..613ae49a05e --- /dev/null +++ b/partner_inherit_company/README.rst @@ -0,0 +1,88 @@ +======================= +Partner inherit company +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:2e28acf6930a8e816f46efd9cf41f5737c081c5021fa38f2f89f0bf3741ee107 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fmulti--company-lightgray.png?logo=github + :target: https://github.com/OCA/multi-company/tree/16.0/partner_inherit_company + :alt: OCA/multi-company +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-partner_inherit_company + :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/multi-company&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Access partners of parent, children and siblings companies. + +This module applies to partners the behavior defined by the mixin "Inherit Company Abstract". + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Aion Tech + +Contributors +~~~~~~~~~~~~ + +* `Aion Tech `_: + + * Simone Rubino + +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. + +.. |maintainer-SirAionTech| image:: https://github.com/SirAionTech.png?size=40px + :target: https://github.com/SirAionTech + :alt: SirAionTech + +Current `maintainer `__: + +|maintainer-SirAionTech| + +This module is part of the `OCA/multi-company `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_inherit_company/__init__.py b/partner_inherit_company/__init__.py new file mode 100644 index 00000000000..1fb11b3be02 --- /dev/null +++ b/partner_inherit_company/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models +from .hooks import post_init_hook diff --git a/partner_inherit_company/__manifest__.py b/partner_inherit_company/__manifest__.py new file mode 100644 index 00000000000..90b4654397b --- /dev/null +++ b/partner_inherit_company/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Partner inherit company", + "summary": "Access partners of parent, children and siblings companies.", + "author": "Aion Tech, Odoo Community Association (OCA)", + "maintainers": [ + "SirAionTech", + ], + "website": "https://github.com/OCA/multi-company" + "/tree/16.0/partner_inherit_company", + "category": "Partner Management", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "depends": [ + "base_inherit_company", + "partner_multi_company", + ], + "post_init_hook": "post_init_hook", +} diff --git a/partner_inherit_company/hooks.py b/partner_inherit_company/hooks.py new file mode 100644 index 00000000000..241506ae3d1 --- /dev/null +++ b/partner_inherit_company/hooks.py @@ -0,0 +1,10 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import SUPERUSER_ID, api + + +def post_init_hook(cr, registry): + env = api.Environment(cr, SUPERUSER_ID, {}) + for partner in env["res.partner"].search([]): + partner.onchange_inherit_company_ids() diff --git a/partner_inherit_company/models/__init__.py b/partner_inherit_company/models/__init__.py new file mode 100644 index 00000000000..fceb1190bf4 --- /dev/null +++ b/partner_inherit_company/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import res_partner diff --git a/partner_inherit_company/models/res_partner.py b/partner_inherit_company/models/res_partner.py new file mode 100644 index 00000000000..070ed279eda --- /dev/null +++ b/partner_inherit_company/models/res_partner.py @@ -0,0 +1,9 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class ResPartner(models.Model): + _inherit = ["inherit.company.abstract", "res.partner"] + _name = "res.partner" diff --git a/partner_inherit_company/readme/CONTRIBUTORS.rst b/partner_inherit_company/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..6afa1541b48 --- /dev/null +++ b/partner_inherit_company/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Aion Tech `_: + + * Simone Rubino diff --git a/partner_inherit_company/readme/DESCRIPTION.rst b/partner_inherit_company/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..778e16fd16d --- /dev/null +++ b/partner_inherit_company/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +Access partners of parent, children and siblings companies. + +This module applies to partners the behavior defined by the mixin "Inherit Company Abstract". diff --git a/partner_inherit_company/static/description/index.html b/partner_inherit_company/static/description/index.html new file mode 100644 index 00000000000..e16d233272d --- /dev/null +++ b/partner_inherit_company/static/description/index.html @@ -0,0 +1,426 @@ + + + + + +Partner inherit company + + + +
+

Partner inherit company

+ + +

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

+

Access partners of parent, children and siblings companies.

+

This module applies to partners the behavior defined by the mixin “Inherit Company Abstract”.

+

Table of contents

+ +
+

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

+
    +
  • Aion Tech
  • +
+
+
+

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.

+

Current maintainer:

+

SirAionTech

+

This module is part of the OCA/multi-company project on GitHub.

+

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

+
+
+
+ + diff --git a/partner_inherit_company/tests/__init__.py b/partner_inherit_company/tests/__init__.py new file mode 100644 index 00000000000..9b37872baed --- /dev/null +++ b/partner_inherit_company/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_partner diff --git a/partner_inherit_company/tests/test_partner.py b/partner_inherit_company/tests/test_partner.py new file mode 100644 index 00000000000..53ed77f65e5 --- /dev/null +++ b/partner_inherit_company/tests/test_partner.py @@ -0,0 +1,33 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests import Form + +from odoo.addons.base_inherit_company.tests.common import Common + + +class TestPartner(Common): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner_model = cls.env["res.partner"] + + def test_inherit_company(self): + """Partners created for an element of a family of companies + are shared to all the companies""" + # Arrange: A family of companies + companies = self.parent_company | self.child_company | self.sibling_company + + # Act: Create a partner for each company + partners = self.partner_model.browse() + for company in companies: + partner_form = Form(self.partner_model.with_company(self.parent_company)) + partner_form.name = "Partner of " + company.name + partner_form.company_ids.clear() + partner_form.company_ids.add(company) + partner = partner_form.save() + partners |= partner + + # Assert: All created partners are shared to every element of the family + for partner in partners: + self.assertEqual(partner.company_ids, companies) diff --git a/setup/partner_inherit_company/odoo/addons/partner_inherit_company b/setup/partner_inherit_company/odoo/addons/partner_inherit_company new file mode 120000 index 00000000000..3cb84027a24 --- /dev/null +++ b/setup/partner_inherit_company/odoo/addons/partner_inherit_company @@ -0,0 +1 @@ +../../../../partner_inherit_company \ No newline at end of file diff --git a/setup/partner_inherit_company/setup.py b/setup/partner_inherit_company/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/partner_inherit_company/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)