diff --git a/base_translation_field_label/README.rst b/base_translation_field_label/README.rst new file mode 100644 index 000000000..908f86102 --- /dev/null +++ b/base_translation_field_label/README.rst @@ -0,0 +1,92 @@ +============================ +Base Translation Field Label +============================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fserver--tools-lightgray.png?logo=github + :target: https://github.com/OCA/server-tools/tree/13.0/base_translation_field_label + :alt: OCA/server-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_translation_field_label + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/149/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon adds the field label on translated terms. Each translated term is +referencing an Odoo field, but the name stated there is not human readable at all, +instead, the field description is shown and the Translated field is hidden at first, +but it can be showed if needed. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +Simply install the module, to access the Settings > Translations > Application Terms +> Translated Terms menu you need to have the Developer Mode enabled. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* `ForgeFlow S.L. `_: + + * Guillem Casassas + +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-GuillemCForgeFlow| image:: https://github.com/GuillemCForgeFlow.png?size=40px + :target: https://github.com/GuillemCForgeFlow + :alt: GuillemCForgeFlow + +Current `maintainer `__: + +|maintainer-GuillemCForgeFlow| + +This module is part of the `OCA/server-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_translation_field_label/__init__.py b/base_translation_field_label/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/base_translation_field_label/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/base_translation_field_label/__manifest__.py b/base_translation_field_label/__manifest__.py new file mode 100644 index 000000000..a257c3823 --- /dev/null +++ b/base_translation_field_label/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Base Translation Field Label", + "summary": """ + Shows the field label and optionally hides the Translated field value. + """, + "version": "15.0.1.0.0", + "category": "Generic Modules/Base", + "license": "AGPL-3", + "website": "https://github.com/OCA/server-tools", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "depends": ["base"], + "data": ["views/ir_translation_views.xml"], + "maintainers": ["GuillemCForgeFlow"], + "installable": True, + "application": False, +} diff --git a/base_translation_field_label/i18n/base_translation_field_label.pot b/base_translation_field_label/i18n/base_translation_field_label.pot new file mode 100644 index 000000000..061b82356 --- /dev/null +++ b/base_translation_field_label/i18n/base_translation_field_label.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_translation_field_label +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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: base_translation_field_label +#: model:ir.model.fields,field_description:base_translation_field_label.field_ir_translation__field_label +msgid "Translated Field" +msgstr "" + +#. module: base_translation_field_label +#: model:ir.model.fields,field_description:base_translation_field_label.field_ir_translation__value +msgid "Translated Value" +msgstr "" + +#. module: base_translation_field_label +#: model:ir.model,name:base_translation_field_label.model_ir_translation +msgid "Translation" +msgstr "" diff --git a/base_translation_field_label/models/__init__.py b/base_translation_field_label/models/__init__.py new file mode 100644 index 000000000..d51399ac5 --- /dev/null +++ b/base_translation_field_label/models/__init__.py @@ -0,0 +1 @@ +from . import ir_translation diff --git a/base_translation_field_label/models/ir_translation.py b/base_translation_field_label/models/ir_translation.py new file mode 100644 index 000000000..e6d183e8a --- /dev/null +++ b/base_translation_field_label/models/ir_translation.py @@ -0,0 +1,22 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models + + +class IrTranslation(models.Model): + _inherit = "ir.translation" + + field_label = fields.Char(string="Translated Field", compute="_compute_field_label") + + value = fields.Text(string="Translated Value") + + @api.depends("name") + def _compute_field_label(self): + for it in self: + field_label = it.name + if it.name and "," in it.name and it.name.count(",") == 1: + model_name, field_name = it.name.split(",") + model = self.env.get(model_name) + if model is not None and field_name in model._fields: + field_label = model._fields[field_name].string + it.field_label = field_label diff --git a/base_translation_field_label/readme/CONFIGURE.rst b/base_translation_field_label/readme/CONFIGURE.rst new file mode 100644 index 000000000..3e90f7a28 --- /dev/null +++ b/base_translation_field_label/readme/CONFIGURE.rst @@ -0,0 +1,2 @@ +Simply install the module, to access the Settings > Translations > Application Terms +> Translated Terms menu you need to have the Developer Mode enabled. diff --git a/base_translation_field_label/readme/CONTRIBUTORS.rst b/base_translation_field_label/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..a502d31e5 --- /dev/null +++ b/base_translation_field_label/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `ForgeFlow S.L. `_: + + * Guillem Casassas diff --git a/base_translation_field_label/readme/DESCRIPTION.rst b/base_translation_field_label/readme/DESCRIPTION.rst new file mode 100644 index 000000000..5fcfafd48 --- /dev/null +++ b/base_translation_field_label/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This addon adds the field label on translated terms. Each translated term is +referencing an Odoo field, but the name stated there is not human readable at all, +instead, the field description is shown and the Translated field is hidden at first, +but it can be showed if needed. diff --git a/base_translation_field_label/static/description/icon.png b/base_translation_field_label/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/base_translation_field_label/static/description/icon.png differ diff --git a/base_translation_field_label/static/description/index.html b/base_translation_field_label/static/description/index.html new file mode 100644 index 000000000..0cf56b31a --- /dev/null +++ b/base_translation_field_label/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Base Translation Field Label + + + +
+

Base Translation Field Label

+ + +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

+

This addon adds the field label on translated terms. Each translated term is +referencing an Odoo field, but the name stated there is not human readable at all, +instead, the field description is shown and the Translated field is hidden at first, +but it can be showed if needed.

+

Table of contents

+ +
+

Configuration

+

Simply install the module, to access the Settings > Translations > Application Terms +> Translated Terms menu you need to have the Developer Mode enabled.

+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+ +
+

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:

+

GuillemCForgeFlow

+

This module is part of the OCA/server-tools project on GitHub.

+

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

+
+
+
+ + diff --git a/base_translation_field_label/tests/__init__.py b/base_translation_field_label/tests/__init__.py new file mode 100644 index 000000000..d0ddf114b --- /dev/null +++ b/base_translation_field_label/tests/__init__.py @@ -0,0 +1 @@ +from . import test_base_transaltion_field_label diff --git a/base_translation_field_label/tests/test_base_transaltion_field_label.py b/base_translation_field_label/tests/test_base_transaltion_field_label.py new file mode 100644 index 000000000..6af1db139 --- /dev/null +++ b/base_translation_field_label/tests/test_base_transaltion_field_label.py @@ -0,0 +1,43 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import TransactionCase + + +class TestBaseTranslationFieldLabel(TransactionCase): + def setUp(self): + super().setUp() + # Models + self.translation_model = self.env["ir.translation"] + self.partner_model = self.env["res.partner"] + self.env.ref("base.lang_ca_ES").active = True + # Set up + self.translation_model._load_module_terms(["base"], ["ca_ES"]) + + # Instances + self.parent_partner = self.partner_model.create({"name": "Parent Partner"}) + self.child_partner = self.partner_model.create( + {"name": "Child Partner", "parent_id": self.parent_partner.id} + ) + self.translated_term = self.translation_model.create( + { + "type": "model", + "name": "res.partner,parent_id", + "module": "base", + "lang": "ca_ES", + "res_id": self.child_partner.id, + "value": "Companyia Relacionada", + "state": "translated", + } + ) + + def test_01_check_field_label(self): + """ + Check that the field label of the translated term matches the string set on the + Odoo field. + """ + self.assertEqual( + self.translated_term.field_label, + "Related Company", + "Field Label on the translated term should match the string value on the " + "Odoo field.", + ) diff --git a/base_translation_field_label/views/ir_translation_views.xml b/base_translation_field_label/views/ir_translation_views.xml new file mode 100644 index 000000000..876dd5c3f --- /dev/null +++ b/base_translation_field_label/views/ir_translation_views.xml @@ -0,0 +1,16 @@ + + + + ir.translation.tree - base_translation_field_label + ir.translation + + + + + + + hide + + + + diff --git a/setup/base_translation_field_label/odoo/addons/base_translation_field_label b/setup/base_translation_field_label/odoo/addons/base_translation_field_label new file mode 120000 index 000000000..593eaf490 --- /dev/null +++ b/setup/base_translation_field_label/odoo/addons/base_translation_field_label @@ -0,0 +1 @@ +../../../../base_translation_field_label \ No newline at end of file diff --git a/setup/base_translation_field_label/setup.py b/setup/base_translation_field_label/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/base_translation_field_label/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)