-
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.
TA#66809 [16.0][MIG] web_custom_modifier (#122)
- Loading branch information
1 parent
a3e13df
commit 5a72a23
Showing
31 changed files
with
809 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
"web", | ||
"resize_observer_error_catcher", | ||
"web_custom_label", | ||
"web_custom_modifier", | ||
|
||
], | ||
"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,117 @@ | ||
=================== | ||
Web Custom Modifier | ||
=================== | ||
This module allows to customize modifiers on form view nodes. | ||
|
||
For example, it allows to make a field readonly, invisible or required. | ||
|
||
.. contents:: Table of Contents | ||
|
||
Usage | ||
----- | ||
As system administrator, I go to `Settings / Technical / User Interface / Custom Modifiers`. | ||
|
||
.. image:: static/description/custom_modifier_menu.png | ||
|
||
I create a new custom modifier. | ||
|
||
.. image:: static/description/new_custom_modifier.png | ||
|
||
The modifier is configured to make the field ``default_code`` of a product required. | ||
|
||
After refreshing my screen, I go to the form view of a product. | ||
|
||
I notice that the field ``default_code`` is required. | ||
|
||
.. image:: static/description/product_form.png | ||
|
||
Advanced Usage | ||
-------------- | ||
In the field ``Type``, I can select ``Xpath``. | ||
This allows to set a modifier for a specific view node, such as a button. | ||
|
||
.. image:: static/description/button_modifier.png | ||
|
||
The example above hides the a button in the form view of a product. | ||
|
||
Hide Selection Item | ||
------------------- | ||
The module allows to hide an item (option) of a selection field. | ||
|
||
.. image:: static/description/hide_selection_item_modifier.png | ||
|
||
The above example hides the type of address ``Other``. | ||
|
||
.. image:: static/description/contact_form_without_selection_item.png | ||
|
||
Beware that if the hidden option is already selected on a record, | ||
it will look as it was never set. | ||
|
||
.. image:: static/description/contact_form_type_not_selected.png | ||
|
||
Therefore, this feature should only be used to hide options that are never used. | ||
|
||
Force Save | ||
---------- | ||
A new option ``Force Save`` is available. | ||
|
||
.. image:: static/description/force_save_modifier.png | ||
|
||
This modifier may be used along with the ``Readonly`` modifier so | ||
that the field value is saved to the server. | ||
|
||
Excluded Groups | ||
--------------- | ||
A new field ``Excluded Groups`` is available. | ||
|
||
.. image:: static/description/excluded_groups.png | ||
|
||
If at least one group of users is selected, the modifier is not applied for users that are member of any of these groups. | ||
|
||
This is useful when rendering an element readonly or invisible only for a subset of users. | ||
|
||
Custom Widget | ||
------------- | ||
It is possible to customize the widget used for a given field. | ||
|
||
.. image:: static/description/custom_widget.png | ||
|
||
.. image:: static/description/task_form_with_custom_widget.png | ||
|
||
Optional | ||
-------- | ||
Also, it is possible to customize the optional of a given field on tree view. | ||
The Optional modifier takes 2 possible keys: "show" or "hide", | ||
- "show": To make the fiead displayed by default in the tree view by default. | ||
- "hide": To make the field hidden in the 3 dotes of a tree view by default. | ||
|
||
*IMPORTANT: the field must be present by default on the tree view and displayed.* | ||
|
||
Example: | ||
As system administrator, I go to `Settings / Technical / User Interface / Custom Modifiers`. | ||
I add the field `name` (label as `Number` in quotation list) of the model `sale.order`. | ||
I select the modifier `Optional` and then set the key `show`. So the field will be shown by default but now, | ||
it is possible now to hide it. | ||
|
||
.. image:: static/description/optional_modifier.png | ||
|
||
I go to quotation list view, I refresh the page, and now I see the change as wanted. | ||
|
||
.. image:: static/description/optional_modifier_applied.png | ||
|
||
Number of lines per page (List Views) | ||
------------------------------------- | ||
|
||
A new modifier is added to set the number of lines per page in list view. | ||
|
||
In the following example, we set a limit of 20 sale order lines per page on a sale order form view. | ||
|
||
.. image:: static/description/number_lines_per_page_modifier.png | ||
|
||
Result: | ||
|
||
.. image:: static/description/sale_order_with_limited_sol_per_page.png | ||
|
||
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-today Numigi 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-today Numigi and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Web Custom Modifier", | ||
"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 modifiers.", | ||
"depends": ["base"], | ||
"data": [ | ||
"views/web_custom_modifier.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,178 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * web_custom_modifier | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2023-06-15 15:07+0000\n" | ||
"PO-Revision-Date: 2023-06-15 15:07+0000\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: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__active | ||
msgid "Active" | ||
msgstr "Actif" | ||
|
||
#. module: web_custom_modifier | ||
#: model_terms:ir.ui.view,arch_db:web_custom_modifier.custom_modifier_search | ||
msgid "Archived" | ||
msgstr "Archivé" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model,name:web_custom_modifier.model_base | ||
msgid "Base" | ||
msgstr "Base" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__create_uid | ||
msgid "Created by" | ||
msgstr "Créé par" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__create_date | ||
msgid "Created on" | ||
msgstr "Créé le" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.actions.act_window,name:web_custom_modifier.custom_modifier_action | ||
#: model:ir.ui.menu,name:web_custom_modifier.custom_modifier_menu | ||
#: model_terms:ir.ui.view,arch_db:web_custom_modifier.custom_modifier_list | ||
#: model_terms:ir.ui.view,arch_db:web_custom_modifier.custom_modifier_search | ||
msgid "Custom Modifiers" | ||
msgstr "Modificateurs personnalisés" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model,name:web_custom_modifier.model_web_custom_modifier | ||
msgid "Custom View Modifier" | ||
msgstr "Modificateurs de vue personnalisés" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__display_name | ||
msgid "Display Name" | ||
msgstr "Nom affiché" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__excluded_group_ids | ||
msgid "Excluded Groups" | ||
msgstr "Groupes exclus" | ||
|
||
#. module: web_custom_modifier | ||
#: model_terms:ir.ui.view,arch_db:web_custom_modifier.custom_modifier_list | ||
#: model_terms:ir.ui.view,arch_db:web_custom_modifier.custom_modifier_search | ||
#: selection:web.custom.modifier,type_:0 | ||
msgid "Field" | ||
msgstr "Champ" | ||
|
||
#. module: web_custom_modifier | ||
#: selection:web.custom.modifier,modifier:0 | ||
msgid "Force Save" | ||
msgstr "Forcer la sauvegarde" | ||
|
||
#. module: web_custom_modifier | ||
#: model_terms:ir.ui.view,arch_db:web_custom_modifier.custom_modifier_search | ||
msgid "Group By" | ||
msgstr "Grouper par" | ||
|
||
#. module: web_custom_modifier | ||
#: selection:web.custom.modifier,modifier:0 | ||
msgid "Hide Selection Item" | ||
msgstr "Cacher un choix de sélection" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: web_custom_modifier | ||
#: selection:web.custom.modifier,modifier:0 | ||
msgid "Invisible" | ||
msgstr "Invisible" | ||
|
||
#. module: web_custom_modifier | ||
#: selection:web.custom.modifier,modifier:0 | ||
msgid "Invisible (List Views)" | ||
msgstr "Invisible (vues listes)" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__key | ||
msgid "Key" | ||
msgstr "Clé" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier____last_update | ||
msgid "Last Modified on" | ||
msgstr "Dernière modification le" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__write_uid | ||
msgid "Last Updated by" | ||
msgstr "Dernière mise à jour par" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__write_date | ||
msgid "Last Updated on" | ||
msgstr "Dernière mise à jour le" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__model_ids | ||
msgid "Model" | ||
msgstr "Modèle" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__modifier | ||
#: model_terms:ir.ui.view,arch_db:web_custom_modifier.custom_modifier_search | ||
msgid "Modifier" | ||
msgstr "Modificateur" | ||
|
||
#. module: web_custom_modifier | ||
#: selection:web.custom.modifier,modifier:0 | ||
msgid "Number of lines per page (List Views)" | ||
msgstr "Nombre de lignes par page (Vues listes)" | ||
|
||
#. module: web_custom_modifier | ||
#: selection:web.custom.modifier,modifier:0 | ||
msgid "Readonly" | ||
msgstr "Lecture seule" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__reference | ||
msgid "Reference" | ||
msgstr "Référence" | ||
|
||
#. module: web_custom_modifier | ||
#: selection:web.custom.modifier,modifier:0 | ||
msgid "Required" | ||
msgstr "Obligatoire" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields,field_description:web_custom_modifier.field_web_custom_modifier__type_ | ||
#: model_terms:ir.ui.view,arch_db:web_custom_modifier.custom_modifier_search | ||
msgid "Type" | ||
msgstr "Type" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model,name:web_custom_modifier.model_ir_ui_view | ||
msgid "View" | ||
msgstr "View" | ||
|
||
#. module: web_custom_modifier | ||
#: selection:web.custom.modifier,modifier:0 | ||
msgid "Widget" | ||
msgstr "Widget" | ||
|
||
#. module: web_custom_modifier | ||
#: selection:web.custom.modifier,type_:0 | ||
msgid "Xpath" | ||
msgstr "Xpath" | ||
|
||
#. module: web_custom_modifier | ||
#: model:ir.model.fields.selection,name:web_custom_modifier.selection__web_custom_modifier__modifier__optional | ||
msgid "Optional" | ||
msgstr "Optionnel" |
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 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_modifier, | ||
) |
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,38 @@ | ||
# Copyright 2023-today Numigi 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_modifiers_on_fields | ||
|
||
|
||
class Base(models.AbstractModel): | ||
|
||
_inherit = "base" | ||
|
||
@api.model | ||
def fields_get(self, allfields=None, attributes=None): | ||
"""Add the custom modifiers to the fields metadata.""" | ||
fields = super().fields_get(allfields, attributes) | ||
modifiers = self.env["web.custom.modifier"].get(self._name) | ||
set_custom_modifiers_on_fields(modifiers, fields) | ||
return fields | ||
|
||
|
||
class Partner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
def name_get(self): | ||
""" | ||
This avoid to load removed selection option in modifiers | ||
that would raise an error when trying to display them. Display instead, | ||
the name of the record. | ||
This could be improved or fixed for each case if needed. | ||
""" | ||
try: | ||
res = super().name_get() | ||
except: # noqa: E722 | ||
res = [] | ||
for partner in self: | ||
name = partner.name | ||
res.append((partner.id, name)) | ||
return res |
Oops, something went wrong.