Skip to content

Commit

Permalink
[IMP] display a helper to add a tooltip on a field. Display the toolt…
Browse files Browse the repository at this point in the history
…ip on list views. One tooltip per field and do not handle user specific tooltips
  • Loading branch information
benwillig committed Aug 1, 2023
1 parent 9974308 commit 3c5ef90
Show file tree
Hide file tree
Showing 14 changed files with 363 additions and 164 deletions.
2 changes: 1 addition & 1 deletion web_field_tooltip/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"data": [
"security/res_groups.xml",
"security/ir_model_access.xml",
"security/ir_rule.xml",
"views/ir_model_fields_tooltip.xml",
"views/res_users.xml",
"views/template.xml",
],
}
43 changes: 30 additions & 13 deletions web_field_tooltip/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-06 07:59+0000\n"
"PO-Revision-Date: 2023-07-06 07:42+0000\n"
"POT-Creation-Date: 2023-08-01 08:24+0000\n"
"PO-Revision-Date: 2023-08-01 08:24+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"
Expand All @@ -25,7 +24,14 @@ msgstr "Une infobulle existe déjà pour ce champ"
#. module: web_field_tooltip
#: model:ir.model.fields,field_description:web_field_tooltip.field_ir_model_fields_tooltip__active
msgid "Active"
msgstr "Active"
msgstr ""

#. module: web_field_tooltip
#. openerp-web
#: code:addons/web_field_tooltip/static/src/js/web_field_tooltip.js:0
#, python-format
msgid "Add a Tooltip"
msgstr "Ajouter une infobulle"

#. module: web_field_tooltip
#: model_terms:ir.ui.view,arch_db:web_field_tooltip.ir_model_fields_tooltip_form_view
Expand Down Expand Up @@ -83,10 +89,15 @@ msgstr "Infobulle de Champ"
msgid "Fields Tooltips"
msgstr "Infobulles"

#. module: web_field_tooltip
#: model:ir.model,name:web_field_tooltip.model_ir_http
msgid "HTTP Routing"
msgstr "Routage HTTP"

#. module: web_field_tooltip
#: model:ir.model.fields,field_description:web_field_tooltip.field_ir_model_fields_tooltip__id
msgid "ID"
msgstr "ID"
msgstr ""

#. module: web_field_tooltip
#: model:ir.model.fields,field_description:web_field_tooltip.field_ir_model_fields_tooltip____last_update
Expand All @@ -113,6 +124,7 @@ msgstr "Dernière mise à jour le"
#. module: web_field_tooltip
#. openerp-web
#: code:addons/web_field_tooltip/static/src/js/web_field_tooltip.js:0
#: code:addons/web_field_tooltip/static/src/js/web_field_tooltip.js:0
#, python-format
msgid "Manage Tooltips"
msgstr "Gérer les Infobulles"
Expand Down Expand Up @@ -143,27 +155,32 @@ msgid "Set active to false to hide the Tooltip without removing it."
msgstr ""
"Mettre le champ actif à faux pour masquer l'Infobulle sans la supprimer."

#. module: web_field_tooltip
#: model:ir.model.fields,field_description:web_field_tooltip.field_res_users__tooltip_show_add_helper
msgid "Show helper to add tooltips on fields"
msgstr "Afficher l'aide pour l'ajout des infobulles sur les champs"

#. module: web_field_tooltip
#: model:res.groups,comment:web_field_tooltip.group_tooltip_manager
msgid "The user will be able to manage all the tooltips."
msgstr "L'utilisateur pourra gérer toutes les infobulles."

#. module: web_field_tooltip
#: model:res.groups,comment:web_field_tooltip.group_tooltip_user
msgid "The user will be able to manage his own tooltips."
msgstr "L'utilisateur pourra gérer ses infobulles."

#. module: web_field_tooltip
#: model:res.groups,name:web_field_tooltip.group_tooltip_manager
msgid "Tooltip Manager"
msgstr "Gestionnaire des infobulles"

#. module: web_field_tooltip
#: model:ir.model.fields,field_description:web_field_tooltip.field_res_users__tooltip_show_add_helper_allowed
msgid "Tooltip Show Add Helper Allowed"
msgstr ""

#. module: web_field_tooltip
#: model:ir.model.fields,field_description:web_field_tooltip.field_ir_model_fields_tooltip__tooltip_text
msgid "Tooltip Text"
msgstr "Texte de l'Infobulle"

#. module: web_field_tooltip
#: model:res.groups,name:web_field_tooltip.group_tooltip_user
msgid "Tooltip User"
msgstr "Utilisateur des infobulles"
#: model:ir.model,name:web_field_tooltip.model_res_users
msgid "Users"
msgstr "Utilisateurs"
35 changes: 26 additions & 9 deletions web_field_tooltip/i18n/web_field_tooltip.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-06 07:59+0000\n"
"PO-Revision-Date: 2023-07-06 07:59+0000\n"
"POT-Creation-Date: 2023-08-01 08:32+0000\n"
"PO-Revision-Date: 2023-08-01 08:32+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -26,6 +26,13 @@ msgstr ""
msgid "Active"
msgstr ""

#. module: web_field_tooltip
#. openerp-web
#: code:addons/web_field_tooltip/static/src/js/web_field_tooltip.js:0
#, python-format
msgid "Add a Tooltip"
msgstr ""

#. module: web_field_tooltip
#: model_terms:ir.ui.view,arch_db:web_field_tooltip.ir_model_fields_tooltip_form_view
#: model_terms:ir.ui.view,arch_db:web_field_tooltip.ir_model_fields_tooltip_search_view
Expand Down Expand Up @@ -82,6 +89,11 @@ msgstr ""
msgid "Fields Tooltips"
msgstr ""

#. module: web_field_tooltip
#: model:ir.model,name:web_field_tooltip.model_ir_http
msgid "HTTP Routing"
msgstr ""

#. module: web_field_tooltip
#: model:ir.model.fields,field_description:web_field_tooltip.field_ir_model_fields_tooltip__id
msgid "ID"
Expand Down Expand Up @@ -143,26 +155,31 @@ msgid "Set active to false to hide the Tooltip without removing it."
msgstr ""

#. module: web_field_tooltip
#: model:res.groups,comment:web_field_tooltip.group_tooltip_manager
msgid "The user will be able to manage all the tooltips."
#: model:ir.model.fields,field_description:web_field_tooltip.field_res_users__tooltip_show_add_helper
msgid "Show helper to add tooltips on fields"
msgstr ""

#. module: web_field_tooltip
#: model:res.groups,comment:web_field_tooltip.group_tooltip_user
msgid "The user will be able to manage his own tooltips."
#: model:res.groups,comment:web_field_tooltip.group_tooltip_manager
msgid "The user will be able to manage all the tooltips."
msgstr ""

#. module: web_field_tooltip
#: model:res.groups,name:web_field_tooltip.group_tooltip_manager
msgid "Tooltip Manager"
msgstr ""

#. module: web_field_tooltip
#: model:ir.model.fields,field_description:web_field_tooltip.field_res_users__tooltip_show_add_helper_allowed
msgid "Tooltip Show Add Helper Allowed"
msgstr ""

#. module: web_field_tooltip
#: model:ir.model.fields,field_description:web_field_tooltip.field_ir_model_fields_tooltip__tooltip_text
msgid "Tooltip Text"
msgstr ""

#. module: web_field_tooltip
#: model:res.groups,name:web_field_tooltip.group_tooltip_user
msgid "Tooltip User"
msgstr ""
#: model:ir.model,name:web_field_tooltip.model_res_users
msgid "Users"
msgstr ""
2 changes: 2 additions & 0 deletions web_field_tooltip/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from . import ir_http
from . import ir_model_fields_tooltip
from . import res_users
19 changes: 19 additions & 0 deletions web_field_tooltip/models/ir_http.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class Http(models.AbstractModel):
_inherit = "ir.http"

def session_info(self):
result = super().session_info()
user = self.env.user
result.update(
{
"can_manage_tooltips": user._is_tooltip_manager(),
"tooltip_show_add_helper": user.tooltip_show_add_helper,
}
)
return result
19 changes: 17 additions & 2 deletions web_field_tooltip/models/ir_model_fields_tooltip.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,27 @@ class IrModelFieldsTooltip(models.Model):
help="Set active to false to hide the Tooltip without removing it.",
)
field_name = fields.Char(related="field_id.name")
tooltip_text = fields.Html(string="Tooltip Text")
tooltip_text = fields.Html(string="Tooltip Text", required=True)

@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
context = self.env.context
default_model = context.get("default_model")
default_field = context.get("default_field_name")
if default_model and default_field:
field = self.env["ir.model.fields"].search(
[("model_id.model", "=", default_model), ("name", "=", default_field)],
limit=1,
)
res.update({"model_id": field.model_id.id, "field_id": field.id})
return res

@api.constrains("model_id", "field_id")
def _check_duplicate_tooltip(self):
all_self = self.with_context(active_test=False)
for rec in self:
if self.search(
if all_self.search(
[
("model_id", "=", rec.model_id.id),
("field_id", "=", rec.field_id.id),
Expand Down
31 changes: 31 additions & 0 deletions web_field_tooltip/models/res_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models

TOOLTIP_MANAGER_GROUP = "web_field_tooltip.group_tooltip_manager"


class ResUsers(models.Model):
_inherit = "res.users"

tooltip_show_add_helper = fields.Boolean(
string="Show helper to add tooltips on fields",
)
tooltip_show_add_helper_allowed = fields.Boolean(
compute="_compute_tooltip_show_add_helper_allowed"
)

def __init__(self, pool, cr):
super().__init__(pool, cr)
field_names = ["tooltip_show_add_helper"]
self.SELF_READABLE_FIELDS.extend(field_names)
self.SELF_WRITEABLE_FIELDS.extend(field_names)

def _compute_tooltip_show_add_helper_allowed(self):
for rec in self:
rec.tooltip_show_add_helper_allowed = rec._is_tooltip_manager()

def _is_tooltip_manager(self):
self.ensure_one()
return self.has_group(TOOLTIP_MANAGER_GROUP)
2 changes: 1 addition & 1 deletion web_field_tooltip/security/ir_model_access.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<record model="ir.model.access" id="ir_model_fields_tooltip_access_user">
<field name="name">ir.model.fields.tooltip access user</field>
<field name="model_id" ref="model_ir_model_fields_tooltip" />
<field name="group_id" ref="web_field_tooltip.group_tooltip_user" />
<field name="group_id" ref="web_field_tooltip.group_tooltip_manager" />
<field name="perm_read" eval="1" />
<field name="perm_create" eval="1" />
<field name="perm_write" eval="1" />
Expand Down
36 changes: 0 additions & 36 deletions web_field_tooltip/security/ir_rule.xml

This file was deleted.

11 changes: 0 additions & 11 deletions web_field_tooltip/security/res_groups.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,9 @@
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record id="group_tooltip_user" model="res.groups">
<field name="name">Tooltip User</field>
<field name="category_id" ref="base.module_category_hidden" />
<field name="implied_ids" eval="[(6, 0, [ref('base.group_user')])]" />
<field name="comment">The user will be able to manage his own tooltips.</field>
</record>

<record id="group_tooltip_manager" model="res.groups">
<field name="name">Tooltip Manager</field>
<field name="category_id" ref="base.module_category_hidden" />
<field
name="implied_ids"
eval="[(6, 0, [ref('web_field_tooltip.group_tooltip_user')])]"
/>
<field name="comment">The user will be able to manage all the tooltips.</field>
<field
name="users"
Expand Down
9 changes: 8 additions & 1 deletion web_field_tooltip/static/src/css/web_field_tooltip.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
sup.field-tooltip {
margin-right: 5px;
}

.tooltip-icon {
color: #666666;
margin-left: 5px;
background: none;
border: none;
display: inline-block;
width: 0;
font-size: 12px;
margin-left: -2px;
}

.popover-footer {
Expand Down
Loading

0 comments on commit 3c5ef90

Please sign in to comment.