diff --git a/partner_name_hide_parent/README.rst b/partner_name_hide_parent/README.rst new file mode 100644 index 00000000000..ba89dc54c5a --- /dev/null +++ b/partner_name_hide_parent/README.rst @@ -0,0 +1,96 @@ +======================== +Partner Name Hide Parent +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:aa7aab9dc950ddc10c08fffe7127f909b843192323543109763593292d3eeb00 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.0/partner_name_hide_parent + :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-17-0/partner-contact-17-0-partner_name_hide_parent + :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/partner-contact&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module does the following: + +- Adds the ability to hide parent's name from the presentation of the + partners' names according to the settings of the partners. + +The function provided by this module is needed when you have to set up a +child partner (e.g. a branch office of a company) as an 'individual' due +to how Odoo recognizes the commercial partner (i.e. if a child partner +is a 'company', the partner becomes the commercial partner itself), and +you do not want to show the parent's name in QWeb report or website +where the partner is referenced (if the child partner is an individual, +Odoo by default shows the parent's name preceding the child's name). + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +For partners you wish to hide their parents' names in their name +presentation, open the partner form and select 'Hide Parent'. + +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 +------- + +* Quartile Limited + +Contributors +------------ + +- `Quartile Limited `__ +- `Binhex `__ + + - Ariel Barreiros (arielbarreiros96) + +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_name_hide_parent/__init__.py b/partner_name_hide_parent/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/partner_name_hide_parent/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_name_hide_parent/__manifest__.py b/partner_name_hide_parent/__manifest__.py new file mode 100644 index 00000000000..3100db24c38 --- /dev/null +++ b/partner_name_hide_parent/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2020-2022 Quartile Limited +# Copyright 2025 Binhex +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Partner Name Hide Parent", + "version": "17.0.1.0.0", + "author": "Quartile Limited,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/partner-contact", + "category": "Extra Tools", + "license": "AGPL-3", + "depends": ["base"], + "data": ["views/res_partner_views.xml"], + "installable": True, +} diff --git a/partner_name_hide_parent/i18n/es.po b/partner_name_hide_parent/i18n/es.po new file mode 100644 index 00000000000..68286c23ee2 --- /dev/null +++ b/partner_name_hide_parent/i18n/es.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_name_hide_parent +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-05-08 18:34+0000\n" +"Last-Translator: Jaime Ruiz Maccione \n" +"Language-Team: none\n" +"Language: es\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: partner_name_hide_parent +#: model:ir.model,name:partner_name_hide_parent.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: partner_name_hide_parent +#: model:ir.model.fields,field_description:partner_name_hide_parent.field_res_partner__hide_parent +#: model:ir.model.fields,field_description:partner_name_hide_parent.field_res_users__hide_parent +msgid "Hide Parent" +msgstr "Ocultar Padre" + +#. module: partner_name_hide_parent +#: model:ir.model.fields,help:partner_name_hide_parent.field_res_partner__hide_parent +#: model:ir.model.fields,help:partner_name_hide_parent.field_res_users__hide_parent +msgid "" +"If selected, the parent's name will not be included in the display name of " +"self." +msgstr "" +"Si esta seleccionado, el nombre del padre no será incluido en el nombre " +"mostrado del mismo." diff --git a/partner_name_hide_parent/i18n/ja.po b/partner_name_hide_parent/i18n/ja.po new file mode 100644 index 00000000000..99dfba10c2c --- /dev/null +++ b/partner_name_hide_parent/i18n/ja.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_name_hide_parent +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-09-13 05:49+0000\n" +"PO-Revision-Date: 2022-09-13 05:49+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: partner_name_hide_parent +#: model:ir.model,name:partner_name_hide_parent.model_res_partner +msgid "Contact" +msgstr "連絡先" + +#. module: partner_name_hide_parent +#: model:ir.model.fields,field_description:partner_name_hide_parent.field_res_partner__hide_parent +#: model:ir.model.fields,field_description:partner_name_hide_parent.field_res_users__hide_parent +msgid "Hide Parent" +msgstr "親を非表示" + +#. module: partner_name_hide_parent +#: model:ir.model.fields,help:partner_name_hide_parent.field_res_partner__hide_parent +#: model:ir.model.fields,help:partner_name_hide_parent.field_res_users__hide_parent +msgid "" +"If selected, the parent's name will not be included in the display name of " +"self." +msgstr "選択された場合、自身の表示名に親の名称が含まれなくなります。" diff --git a/partner_name_hide_parent/i18n/partner_name_hide_parent.pot b/partner_name_hide_parent/i18n/partner_name_hide_parent.pot new file mode 100644 index 00000000000..860513713e0 --- /dev/null +++ b/partner_name_hide_parent/i18n/partner_name_hide_parent.pot @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_name_hide_parent +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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: partner_name_hide_parent +#: model:ir.model,name:partner_name_hide_parent.model_res_partner +msgid "Contact" +msgstr "" + +#. module: partner_name_hide_parent +#: model:ir.model.fields,field_description:partner_name_hide_parent.field_res_partner__hide_parent +#: model:ir.model.fields,field_description:partner_name_hide_parent.field_res_users__hide_parent +msgid "Hide Parent" +msgstr "" + +#. module: partner_name_hide_parent +#: model:ir.model.fields,help:partner_name_hide_parent.field_res_partner__hide_parent +#: model:ir.model.fields,help:partner_name_hide_parent.field_res_users__hide_parent +msgid "" +"If selected, the parent's name will not be included in the display name of " +"self." +msgstr "" diff --git a/partner_name_hide_parent/models/__init__.py b/partner_name_hide_parent/models/__init__.py new file mode 100644 index 00000000000..91fed54d404 --- /dev/null +++ b/partner_name_hide_parent/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/partner_name_hide_parent/models/res_partner.py b/partner_name_hide_parent/models/res_partner.py new file mode 100644 index 00000000000..b21c4af7d63 --- /dev/null +++ b/partner_name_hide_parent/models/res_partner.py @@ -0,0 +1,49 @@ +# Copyright 2020-2022 Quartile Limited +# Copyright 2025 Binhex +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + hide_parent = fields.Boolean( + help="If selected, the parent's name will not be included in the " + "display name of self." + ) + + def _get_complete_name(self): + self.ensure_one() + complete_name = super()._get_complete_name() + if not self.hide_parent: + return complete_name + + displayed_types = self._complete_name_displayed_types + type_description = dict(self._fields["type"]._description_selection(self.env)) + name = self.name or "" + if self.company_name or self.parent_id: + if not name and self.type in displayed_types: + name = type_description.get(self.type, "") + return name.strip() or complete_name + + # Just add "hide_parent" as a trigger. + @api.depends( + "complete_name", + "email", + "vat", + "state_id", + "country_id", + "commercial_company_name", + "hide_parent", + ) + @api.depends_context( + "show_address", + "partner_show_db_id", + "address_inline", + "show_email", + "show_vat", + "lang", + ) + def _compute_display_name(self): + return super()._compute_display_name() diff --git a/partner_name_hide_parent/pyproject.toml b/partner_name_hide_parent/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/partner_name_hide_parent/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/partner_name_hide_parent/readme/CONTRIBUTORS.md b/partner_name_hide_parent/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..99bfd21f047 --- /dev/null +++ b/partner_name_hide_parent/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Quartile Limited](https://www.quartile.co) +- [Binhex](https://www.binhex.cloud) + - Ariel Barreiros (arielbarreiros96) diff --git a/partner_name_hide_parent/readme/DESCRIPTION.md b/partner_name_hide_parent/readme/DESCRIPTION.md new file mode 100644 index 00000000000..238617edc6f --- /dev/null +++ b/partner_name_hide_parent/readme/DESCRIPTION.md @@ -0,0 +1,12 @@ +This module does the following: + +- Adds the ability to hide parent's name from the presentation of the + partners' names according to the settings of the partners. + +The function provided by this module is needed when you have to set up a +child partner (e.g. a branch office of a company) as an 'individual' due +to how Odoo recognizes the commercial partner (i.e. if a child partner +is a 'company', the partner becomes the commercial partner itself), and +you do not want to show the parent's name in QWeb report or website +where the partner is referenced (if the child partner is an individual, +Odoo by default shows the parent's name preceding the child's name). diff --git a/partner_name_hide_parent/readme/USAGE.md b/partner_name_hide_parent/readme/USAGE.md new file mode 100644 index 00000000000..1eda818c544 --- /dev/null +++ b/partner_name_hide_parent/readme/USAGE.md @@ -0,0 +1,2 @@ +For partners you wish to hide their parents' names in their name +presentation, open the partner form and select 'Hide Parent'. diff --git a/partner_name_hide_parent/static/description/icon.png b/partner_name_hide_parent/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/partner_name_hide_parent/static/description/icon.png differ diff --git a/partner_name_hide_parent/static/description/index.html b/partner_name_hide_parent/static/description/index.html new file mode 100644 index 00000000000..77b23612932 --- /dev/null +++ b/partner_name_hide_parent/static/description/index.html @@ -0,0 +1,444 @@ + + + + + +Partner Name Hide Parent + + + +
+

Partner Name Hide Parent

+ + +

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

+

This module does the following:

+
    +
  • Adds the ability to hide parent’s name from the presentation of the +partners’ names according to the settings of the partners.
  • +
+

The function provided by this module is needed when you have to set up a +child partner (e.g. a branch office of a company) as an ‘individual’ due +to how Odoo recognizes the commercial partner (i.e. if a child partner +is a ‘company’, the partner becomes the commercial partner itself), and +you do not want to show the parent’s name in QWeb report or website +where the partner is referenced (if the child partner is an individual, +Odoo by default shows the parent’s name preceding the child’s name).

+

Table of contents

+ +
+

Usage

+

For partners you wish to hide their parents’ names in their name +presentation, open the partner form and select ‘Hide Parent’.

+
+
+

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

+
    +
  • Quartile Limited
  • +
+
+
+

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_name_hide_parent/tests/__init__.py b/partner_name_hide_parent/tests/__init__.py new file mode 100644 index 00000000000..884e7160068 --- /dev/null +++ b/partner_name_hide_parent/tests/__init__.py @@ -0,0 +1 @@ +from . import test_partner_name_hide_parent diff --git a/partner_name_hide_parent/tests/test_partner_name_hide_parent.py b/partner_name_hide_parent/tests/test_partner_name_hide_parent.py new file mode 100644 index 00000000000..707e6758480 --- /dev/null +++ b/partner_name_hide_parent/tests/test_partner_name_hide_parent.py @@ -0,0 +1,28 @@ +# Copyright 2020-2022 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestPartnerNameHideParent(TransactionCase): + def test_display_name(self): + test_parent = self.env["res.partner"].create( + {"name": "parent", "is_company": True} + ) + test_child = self.env["res.partner"].create( + { + "name": "child", + "is_company": False, + "parent_id": test_parent.id, + "hide_parent": True, + } + ) + self.assertEqual(test_child.display_name, "child") + + # Confirm that a change on "hide_parent" works as expected as a + # trigger to update display_name + test_child.write({"hide_parent": False}) + self.assertEqual(test_child.display_name, "parent, child") + + test_child.write({"hide_parent": True}) + self.assertEqual(test_child.display_name, "child") diff --git a/partner_name_hide_parent/views/res_partner_views.xml b/partner_name_hide_parent/views/res_partner_views.xml new file mode 100644 index 00000000000..c90eec3f1a7 --- /dev/null +++ b/partner_name_hide_parent/views/res_partner_views.xml @@ -0,0 +1,16 @@ + + + + res.partner.form + res.partner + + + + + + + + + + +