-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f285f69
commit ad7793d
Showing
30 changed files
with
934 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
"depends": [ | ||
"web", | ||
"resize_observer_error_catcher", | ||
"web_custom_label", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Web Custom Label | ||
|
||
This module allows to easily modify the labels of a view without any development. | ||
|
||
## Customizing Labels | ||
|
||
In order to edit a label, you need to: | ||
|
||
* Go to `Settings / Translations / Application Terms / Custom Labels`. | ||
* Add a new custom label. | ||
* Refresh your browser session in order to see the new label in your view. | ||
|
||
Here is an example for products. We rename the field `Internal Reference` (default_code) with `SKU`. | ||
|
||
![Custom Field List](static/description/custom_field_list.png?raw=true) | ||
|
||
Note that we selected 2 models to modify; `Product` and `Product Template`. | ||
This means we are modifying the label for both product templates and variants. | ||
|
||
Now, if we go to any for product form view, we get the new label `SKU`. | ||
|
||
![Product List](static/description/product_list.png?raw=true) | ||
|
||
![Product Form](static/description/product_form.png?raw=true) | ||
|
||
custom_field_list.png | ||
|
||
## Customizing Placeholers | ||
|
||
The module also allows to modify the placeholders of a form view. | ||
|
||
Here, we set custom placeholders on the street fields of partners / addresses. | ||
|
||
![Placeholder List](static/description/custom_placeholder_list.png?raw=true) | ||
|
||
Partners have multiple form views in Odoo. | ||
|
||
Here, we did not have to specify which form view to edit. | ||
The new placeholders are set in both the main partner form and the contact address form. | ||
|
||
![Partner Form](static/description/partner_form_with_placeholders.png?raw=true) | ||
|
||
![Address Form](static/description/address_form_with_placeholders.png?raw=true) | ||
|
||
## Customizing Helpers | ||
|
||
It is possible to customize a field helper. | ||
|
||
![Custom Field Help](static/description/custom_field_help.png?raw=true) | ||
|
||
![Contact Field Help](static/description/contact_field_help.png?raw=true) | ||
|
||
## Customizing Selection Fields | ||
|
||
Fields of type ``Selection`` can be customized. | ||
|
||
In the list view of custom labels, a new position ``Selection`` and a column ``Key`` were added. | ||
The ``Key`` contains the technical value of the selection option to rename. | ||
|
||
![Custom Selection Option](static/description/custom_selection_option.png?raw=true) | ||
|
||
In the example above, the option ``contact`` of the field ``type`` of ``res.partner`` | ||
was renamed to ``Personne`` (in french). | ||
|
||
In the form view of a contact, the term ``Contact`` is replaced with ``Personne``. | ||
|
||
![Partner Contact Type](static/description/partner_contact_type.png?raw=true) | ||
|
||
## Customizing Buttons | ||
|
||
In order to customize an element of the view that is not a field, we need to target the element with an Xpath expression. | ||
|
||
Let's say we want to customize the stock picking view and change the `VALIDATE` button to `TRANSFER`. | ||
|
||
![Picking Form Before](static/description/picking_form_before.png?raw=true) | ||
|
||
We add the custom label using an Xpath expression. | ||
|
||
![Picking Custom Label](static/description/picking_custom_label.png?raw=true) | ||
|
||
Then, the label is updated on the button. | ||
|
||
![Picking Form After](static/description/picking_form_after.png?raw=true) | ||
|
||
## Comparison with Odoo Studio | ||
|
||
When using Odoo Studio to modify a label, an inherited view is created behind the scene. | ||
Thus, each label added using Odoo Studio is coupled with the code. | ||
It adds complexity to deployments, because if the inherited view changes, | ||
the Studio customization may become incompatible. | ||
|
||
Another downside is that when using Studio, you will need to edit every view of your model. | ||
For example, products and partners have multiple form views. If you change one label, you will | ||
need to change at multiple places. | ||
|
||
The module `Web Custom Label` does not add additionnal XML. | ||
It modifies the view at the rendering, according to the language of the user. | ||
If the inherited view changes, the system will not fail. | ||
You may however end up with a wrong label inside a view and have to adjust the custom label entry. | ||
|
||
Contributors | ||
------------ | ||
* Numigi (tm) and all its contributors (https://bit.ly/numigiens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import models | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Web Custom Label", | ||
"version": "16.0.1.0.0", | ||
"author": "Numigi", | ||
"maintainer": "Numigi", | ||
"website": "https://bit.ly/numigi-com", | ||
"license": "LGPL-3", | ||
"category": "Project", | ||
"summary": "Enable easily customizing view labels.", | ||
"depends": ["base"], | ||
"data": [ | ||
"views/custom_label.xml", | ||
"security/ir.model.access.csv", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * web_custom_label | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-02-17 19:52+0000\n" | ||
"PO-Revision-Date: 2024-07-04 14:52-0500\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"Language: fr\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: \n" | ||
"X-Generator: Poedit 2.0.6\n" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__active | ||
msgid "Active" | ||
msgstr "Actif" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model,name:web_custom_label.model_base | ||
msgid "Base" | ||
msgstr "" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__create_uid | ||
msgid "Created by" | ||
msgstr "Créé par" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__create_date | ||
msgid "Created on" | ||
msgstr "Créé le" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.actions.act_window,name:web_custom_label.custom_label_action | ||
#: model:ir.ui.menu,name:web_custom_label.custom_label_menu | ||
#: model_terms:ir.ui.view,arch_db:web_custom_label.custom_label_list | ||
#: model_terms:ir.ui.view,arch_db:web_custom_label.custom_label_search | ||
msgid "Custom Labels" | ||
msgstr "Libellés personnalisés" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model,name:web_custom_label.model_web_custom_label | ||
msgid "Custom View Label" | ||
msgstr "Libellés de vue personnalisés" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__display_name | ||
msgid "Display Name" | ||
msgstr "Nom affiché" | ||
|
||
#. module: web_custom_label | ||
#: model_terms:ir.ui.view,arch_db:web_custom_label.custom_label_list | ||
#: model_terms:ir.ui.view,arch_db:web_custom_label.custom_label_search | ||
#: selection:web.custom.label,type_:0 | ||
msgid "Field" | ||
msgstr "Champ" | ||
|
||
#. module: web_custom_label | ||
#: model_terms:ir.ui.view,arch_db:web_custom_label.custom_label_search | ||
msgid "Group By" | ||
msgstr "Grouper par" | ||
|
||
#. module: web_custom_label | ||
#: selection:web.custom.label,position:0 | ||
msgid "Help" | ||
msgstr "Aide" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__key | ||
msgid "Key" | ||
msgstr "Clé" | ||
|
||
#. module: web_custom_label | ||
#: selection:web.custom.label,position:0 | ||
msgid "Label" | ||
msgstr "Libellé" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__lang | ||
#: model_terms:ir.ui.view,arch_db:web_custom_label.custom_label_search | ||
msgid "Language" | ||
msgstr "Langue" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label____last_update | ||
msgid "Last Modified on" | ||
msgstr "Dernière modification le" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__write_uid | ||
msgid "Last Updated by" | ||
msgstr "Dernière mise à jour par" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__write_date | ||
msgid "Last Updated on" | ||
msgstr "Dernière mise à jour le" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__model_ids | ||
msgid "Model" | ||
msgstr "Modèle" | ||
|
||
#. module: web_custom_label | ||
#: selection:web.custom.label,position:0 | ||
msgid "Placeholder" | ||
msgstr "Texte substitution (placeholder)" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__position | ||
msgid "Position" | ||
msgstr "Position" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__reference | ||
msgid "Reference" | ||
msgstr "Référence" | ||
|
||
#. module: web_custom_label | ||
#: selection:web.custom.label,position:0 | ||
msgid "Selection" | ||
msgstr "Sélection" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__term | ||
msgid "Term" | ||
msgstr "Terme" | ||
|
||
#. module: web_custom_label | ||
#: model_terms:ir.ui.view,arch_db:web_custom_label.custom_label_search | ||
msgid "Type" | ||
msgstr "Type" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model.fields,field_description:web_custom_label.field_web_custom_label__type_ | ||
msgid "Type " | ||
msgstr "Type" | ||
|
||
#. module: web_custom_label | ||
#: model:ir.model,name:web_custom_label.model_ir_ui_view | ||
msgid "View" | ||
msgstr "Vue" | ||
|
||
#. module: web_custom_label | ||
#: selection:web.custom.label,type_:0 | ||
msgid "Xpath" | ||
msgstr "Xpath" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import ( | ||
base, | ||
ir_ui_view, | ||
web_custom_label, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import api, models | ||
from .common import set_custom_labels_on_fields | ||
|
||
|
||
class Base(models.AbstractModel): | ||
|
||
_inherit = "base" | ||
|
||
@api.model | ||
def fields_get(self, allfields=None, attributes=None): | ||
"""Add the custom labels to the fields metadata. | ||
The method is used to query the fields metadata. | ||
This data is used by search filters / group by to display the field names. | ||
""" | ||
fields = super().fields_get(allfields, attributes) | ||
lang = self.env.context.get("lang") or self.env.user.lang | ||
labels = self.env["web.custom.label"].get(self._name, lang) | ||
set_custom_labels_on_fields(labels, fields) | ||
return fields |
Oops, something went wrong.