diff --git a/partner_industry_secondary/README.rst b/partner_industry_secondary/README.rst index 9eb0612b497..a7cc7c7b6b4 100644 --- a/partner_industry_secondary/README.rst +++ b/partner_industry_secondary/README.rst @@ -84,6 +84,7 @@ Contributors * Jordi Ballester Alomar * Miquel Raïch * Cristina Martin R. +* Eduardo de Miguel `Moduon `_ Maintainers ~~~~~~~~~~~ diff --git a/partner_industry_secondary/i18n/es.po b/partner_industry_secondary/i18n/es.po index 8ad1d7600f8..ef059d9ab8f 100644 --- a/partner_industry_secondary/i18n/es.po +++ b/partner_industry_secondary/i18n/es.po @@ -1,23 +1,21 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * partner_sector +# * partner_industry_secondary # -# Translators: -# OCA Transbot , 2017 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-12-26 15:33+0000\n" -"PO-Revision-Date: 2023-10-12 13:38+0000\n" -"Last-Translator: Ivorra78 \n" -"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"POT-Creation-Date: 2025-01-13 12:12+0000\n" +"PO-Revision-Date: 2025-01-13 13:13+0100\n" +"Last-Translator: \n" +"Language-Team: \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" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.4.4\n" #. module: partner_industry_secondary #: model:ir.model.fields,field_description:partner_industry_secondary.field_res_partner_industry__child_ids @@ -27,13 +25,24 @@ msgstr "Hijos" #. module: partner_industry_secondary #: model:ir.model,name:partner_industry_secondary.model_res_config_settings msgid "Config Settings" -msgstr "Configura los ajustes" +msgstr "Ajustes de configuración" #. module: partner_industry_secondary #: model:ir.model,name:partner_industry_secondary.model_res_partner msgid "Contact" msgstr "Contacto" +#. module: partner_industry_secondary +#: model:ir.model.fields,field_description:partner_industry_secondary.field_res_config_settings__display_last_child_first +#: model_terms:ir.ui.view,arch_db:partner_industry_secondary.res_config_settings_view_form +msgid "Display Child Industries first" +msgstr "Mostrar Industrias Hijas primero" + +#. module: partner_industry_secondary +#: model_terms:ir.ui.view,arch_db:partner_industry_secondary.res_config_settings_view_form +msgid "Display like: Child (Dad < Grampa < Ancestor)" +msgstr "Display like Child (Dad < Grampa < Ancestor)" + #. module: partner_industry_secondary #: model_terms:ir.ui.view,arch_db:partner_industry_secondary.res_config_settings_view_form msgid "Enable industries for individuals" @@ -61,7 +70,7 @@ msgstr "Sector" #: model:ir.model.fields,field_description:partner_industry_secondary.field_res_partner__industry_id #: model:ir.model.fields,field_description:partner_industry_secondary.field_res_users__industry_id msgid "Main Industry" -msgstr "Sector principal" +msgstr "Sector" #. module: partner_industry_secondary #: model:ir.model.fields,field_description:partner_industry_secondary.field_res_partner_industry__name @@ -94,6 +103,15 @@ msgstr "Sector" msgid "Set if you want to be able to use industries for individuals also." msgstr "Establezca si desea poder usar sectores para individuos también." +#. module: partner_industry_secondary +#: model:ir.model.fields,help:partner_industry_secondary.field_res_config_settings__display_last_child_first +msgid "" +"Set if you want to show the last child industries first when searching for industries.\n" +"Child (Dad < Grampa < Ancestor)" +msgstr "" +"Márcalo si quieres mostrar la última industria hija primero cuando busques por industrias.\n" +"Hija (Padre < Abuelo < Ancestro)" + #. module: partner_industry_secondary #: model:ir.model.fields,field_description:partner_industry_secondary.field_res_partner__show_partner_industry_for_person #: model:ir.model.fields,field_description:partner_industry_secondary.field_res_users__show_partner_industry_for_person @@ -105,54 +123,10 @@ msgstr "Mostrar socio Industria Para persona" #: code:addons/partner_industry_secondary/models/res_partner.py:0 #, python-format msgid "The main industry must be different from the secondary industries." -msgstr "" -"La industria principal debe ser diferente de las industrias secundarias." +msgstr "La industria principal debe ser diferente de las industrias secundarias." #. module: partner_industry_secondary #: model:ir.model.fields,field_description:partner_industry_secondary.field_res_config_settings__group_use_partner_industry_for_person #: model:res.groups,name:partner_industry_secondary.group_use_partner_industry_for_person msgid "Use industry for individuals" msgstr "Use el sector para individuos" - -#, python-format -#~ msgid "Error! You cannot create recursive industries." -#~ msgstr "Error!. No puede crear sectores recursivos." - -#~ msgid "Industry for individual" -#~ msgstr "Sector para personas" - -#~ msgid "Partner Industries" -#~ msgstr "Sectores de la empresa" - -#~ msgid "Parent Right" -#~ msgstr "Padre derecha" - -#~ msgid "Created by" -#~ msgstr "Creado por" - -#~ msgid "Created on" -#~ msgstr "Creado en" - -#~ msgid "Display Name" -#~ msgstr "Nombre mostrado" - -#~ msgid "ID" -#~ msgstr "ID" - -#~ msgid "Last Modified on" -#~ msgstr "Última modificación el" - -#~ msgid "Last Updated by" -#~ msgstr "Última actualización por" - -#~ msgid "Last Updated on" -#~ msgstr "Última actualización en" - -#~ msgid "Main Sector" -#~ msgstr "Sector principal" - -#~ msgid "Partner" -#~ msgstr "Empresa" - -#~ msgid "Sectors" -#~ msgstr "Sectores" diff --git a/partner_industry_secondary/i18n/partner_industry_secondary.pot b/partner_industry_secondary/i18n/partner_industry_secondary.pot index 87e1172fe26..21f04622524 100644 --- a/partner_industry_secondary/i18n/partner_industry_secondary.pot +++ b/partner_industry_secondary/i18n/partner_industry_secondary.pot @@ -6,6 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-01-13 12:12+0000\n" +"PO-Revision-Date: 2025-01-13 12:12+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -28,6 +30,17 @@ msgstr "" msgid "Contact" msgstr "" +#. module: partner_industry_secondary +#: model:ir.model.fields,field_description:partner_industry_secondary.field_res_config_settings__display_last_child_first +#: model_terms:ir.ui.view,arch_db:partner_industry_secondary.res_config_settings_view_form +msgid "Display Child Industries first" +msgstr "" + +#. module: partner_industry_secondary +#: model_terms:ir.ui.view,arch_db:partner_industry_secondary.res_config_settings_view_form +msgid "Display like: Child (Dad < Grampa < Ancestor)" +msgstr "" + #. module: partner_industry_secondary #: model_terms:ir.ui.view,arch_db:partner_industry_secondary.res_config_settings_view_form msgid "Enable industries for individuals" @@ -88,6 +101,13 @@ msgstr "" msgid "Set if you want to be able to use industries for individuals also." msgstr "" +#. module: partner_industry_secondary +#: model:ir.model.fields,help:partner_industry_secondary.field_res_config_settings__display_last_child_first +msgid "" +"Set if you want to show the last child industries first when searching for industries.\n" +"Child (Dad < Grampa < Ancestor)" +msgstr "" + #. module: partner_industry_secondary #: model:ir.model.fields,field_description:partner_industry_secondary.field_res_partner__show_partner_industry_for_person #: model:ir.model.fields,field_description:partner_industry_secondary.field_res_users__show_partner_industry_for_person diff --git a/partner_industry_secondary/models/res_config_settings.py b/partner_industry_secondary/models/res_config_settings.py index f3564f4c3f5..47f3e0be7c0 100644 --- a/partner_industry_secondary/models/res_config_settings.py +++ b/partner_industry_secondary/models/res_config_settings.py @@ -1,4 +1,5 @@ # Copyright 2018 Eficent Business and IT Consulting Services, S.L. +# Copyright 2025 Moduon - Eduardo de Miguel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import fields, models @@ -12,3 +13,9 @@ class ResConfigSettings(models.TransientModel): help="Set if you want to be able to use industries for individuals also.", implied_group="partner_industry_secondary.group_use_partner_industry_for_person", ) + display_last_child_first = fields.Boolean( + string="Display Child Industries first", + help="Set if you want to show the last child industries first " + "when searching for industries.\nChild (Dad < Grampa < Ancestor)", + config_parameter="partner_industry_secondary.display_last_child_first", + ) diff --git a/partner_industry_secondary/models/res_partner_industry.py b/partner_industry_secondary/models/res_partner_industry.py index 0aeefe448fb..3e1462451e5 100644 --- a/partner_industry_secondary/models/res_partner_industry.py +++ b/partner_industry_secondary/models/res_partner_industry.py @@ -3,6 +3,7 @@ # Copyright 2016 Tecnativa S.L. - Pedro M. Baeza # Copyright 2018 Eficent Business and IT Consulting Services, S.L. # Copyright 2019 Tecnativa - Cristina Martin R. +# Copyright 2025 Moduon - Eduardo de Miguel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import _, api, exceptions, fields, models @@ -28,11 +29,25 @@ def get_names(cat): """Return the list [cat.name, cat.parent_id.name, ...]""" res = [] while cat: - res.insert(0, cat.name) + res.append(cat.name) cat = cat.parent_id return res - return [(cat.id, " / ".join(get_names(cat))) for cat in self] + if ( + self.env["ir.config_parameter"] + .sudo() + .get_param("partner_industry_secondary.display_last_child_first") + ): + # Display last child first + result = [] + for cat in self: + cat_name, *parent_cats = get_names(cat) + if parent_cats: + cat_name = f"{cat_name} ({' < '.join(parent_cats)})" + result.append((cat.id, cat_name)) + return result + # Default display (Ancestor / Grandpa / Dad / Child) + return [(cat.id, " / ".join(get_names(cat)[::-1])) for cat in self] @api.constrains("name", "parent_id") def _check_uniq_name(self): diff --git a/partner_industry_secondary/readme/CONTRIBUTORS.rst b/partner_industry_secondary/readme/CONTRIBUTORS.rst index b9e3b9b763d..b037f7dfcbb 100644 --- a/partner_industry_secondary/readme/CONTRIBUTORS.rst +++ b/partner_industry_secondary/readme/CONTRIBUTORS.rst @@ -7,3 +7,4 @@ * Jordi Ballester Alomar * Miquel Raïch * Cristina Martin R. +* Eduardo de Miguel `Moduon `_ diff --git a/partner_industry_secondary/static/description/index.html b/partner_industry_secondary/static/description/index.html index 9eea72ad331..d0613022a39 100644 --- a/partner_industry_secondary/static/description/index.html +++ b/partner_industry_secondary/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -431,12 +432,15 @@

Contributors

  • Jordi Ballester Alomar <jordi.ballester@eficent.com>
  • Miquel Raïch <miquel.raich@eficent.com>
  • Cristina Martin R.
  • +
  • Eduardo de Miguel Moduon
  • Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +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.

    diff --git a/partner_industry_secondary/tests/test_res_partner_industry.py b/partner_industry_secondary/tests/test_res_partner_industry.py index 6d21713dd41..dba427f4836 100644 --- a/partner_industry_secondary/tests/test_res_partner_industry.py +++ b/partner_industry_secondary/tests/test_res_partner_industry.py @@ -1,6 +1,7 @@ # Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta # Copyright 2016 Tecnativa S.L. - Vicent Cubells # Copyright 2016 Tecnativa S.L. - Pedro M. Baeza +# Copyright 2025 Moduon - Eduardo de Miguel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo.exceptions import UserError, ValidationError @@ -13,10 +14,17 @@ def setUpClass(cls): super(TestResPartnerIndustry, cls).setUpClass() cls.industry_model = cls.env["res.partner.industry"] cls.industry_main = cls.industry_model.create({"name": "Test"}) + cls.industry_dad = cls.industry_model.create( + {"name": "Test dad", "parent_id": cls.industry_main.id} + ) cls.industry_child = cls.industry_model.create( - {"name": "Test child", "parent_id": cls.industry_main.id} + {"name": "Test child", "parent_id": cls.industry_dad.id} ) cls.partner = cls.env["res.partner"].create({"name": "Test partner"}) + # Ensure the parameter is not set + cls.env["ir.config_parameter"].search( + [("key", "=", "partner_industry_secondary.display_last_child_first")] + ).unlink() def test_00_check_industries(self): with self.assertRaises(ValidationError): @@ -41,12 +49,25 @@ def test_03_check_recursion(self): self.industry_main.parent_id = self.industry_child.id def test_04_name(self): - self.assertEqual(self.industry_child.display_name, "Test / Test child") + self.assertEqual( + self.industry_child.display_name, "Test / Test dad / Test child" + ) def test_05_check_partner_industries(self): - main = self.industry_main - both = self.industry_main | self.industry_child + all_industries = self.industry_main | self.industry_dad | self.industry_child with self.assertRaises(ValidationError): self.partner.write( - {"industry_id": main.id, "secondary_industry_ids": [(6, 0, both.ids)]} + { + "industry_id": self.industry_main.id, + "secondary_industry_ids": [(6, 0, all_industries.ids)], + } ) + + def test_06_child_name_first(self): + self.env["ir.config_parameter"].set_param( + "partner_industry_secondary.display_last_child_first", "True" + ) + self.assertEqual( + self.industry_child.display_name, + "Test child (Test dad < Test)", + ) diff --git a/partner_industry_secondary/views/res_config_settings.xml b/partner_industry_secondary/views/res_config_settings.xml index c4a8e901f6d..b215496e150 100644 --- a/partner_industry_secondary/views/res_config_settings.xml +++ b/partner_industry_secondary/views/res_config_settings.xml @@ -1,5 +1,6 @@ @@ -41,6 +42,21 @@
    +
    + +
    +
    +