-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by dreispt
- Loading branch information
Showing
15 changed files
with
221 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../web_tooltip_field |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
Empty file.
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 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import models | ||
from .patch import post_load |
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,20 @@ | ||
# Copyright 2023 Komit - Cuong Nguyen Mtm | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Web Tooltip Field", | ||
"version": "14.0.1.0.0", | ||
"summary": "Showing a Field ToolTip in Odoo", | ||
"category": "Tools", | ||
"website": "https://github.com/OCA/web", | ||
"author": "KOMIT, Odoo Community Association (OCA)", | ||
"maintainers": ["cuongnmtm"], | ||
"license": "AGPL-3", | ||
"depends": ["base", "web"], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/ir_model_fields_help_tooltip_view.xml", | ||
], | ||
"post_load": "post_load", | ||
"application": False, | ||
"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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import ir_model_fields_help_tooltip |
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,24 @@ | ||
# Copyright 2023 Komit - Cuong Nguyen Mtm | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class IrModelFieldsHelpTooltip(models.Model): | ||
_name = "ir.model.fields.help.tooltip" | ||
_description = "Help Tooltip for Fields" | ||
_rec_name = "field_id" | ||
|
||
field_id = fields.Many2one( | ||
"ir.model.fields", required=True, ondelete="cascade", index=True | ||
) | ||
model = fields.Char(related="field_id.model", store=True) | ||
help = fields.Text(translate=True) | ||
|
||
_sql_constraints = [ | ||
( | ||
"field_id_uniq", | ||
"unique(field_id)", | ||
"Help Tooltip for Field already exists!", | ||
), | ||
] |
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,27 @@ | ||
import logging | ||
|
||
from odoo.fields import Field | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
_former_field_description_help = Field._description_help | ||
|
||
|
||
def _description_help(self, env): | ||
model_name = self.base_field.model_name | ||
help_tooltip = env["ir.model.fields.help.tooltip"].search( | ||
[ | ||
("field_id.name", "=", self.name), | ||
("model", "=", model_name), | ||
("help", "!=", ""), | ||
], | ||
limit=1, | ||
) | ||
if help_tooltip: | ||
return help_tooltip.help | ||
return _former_field_description_help(self, env) | ||
|
||
|
||
def post_load(): | ||
_logger.info("Aplying patch web_tooltip_field ...") | ||
Field._description_help = _description_help |
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,3 @@ | ||
* `Komit <https://komit-consulting.com>`_: | ||
|
||
* Cuong Nguyen Mtm <cuong.nmtm@komit-consulting.com> |
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 @@ | ||
The development of this module has been financially supported by: | ||
|
||
- Scaleway SAS (https://www.scaleway.com/) | ||
- Komit (https://komit-consulting.com) |
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,7 @@ | ||
Configure | ||
========= | ||
* Open debug mode. | ||
* Go to Setting > Fields Help Tooltip. | ||
* Choose a field and insert your help message for that field. | ||
|
||
Then there will be a help message displayed when you mouserover it. |
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,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_ir_model_fields_help_tooltip,ir.model.fields.help.tooltip,model_ir_model_fields_help_tooltip,base.group_system,1,1,1,1 | ||
access_ir_model_fields_help_tooltip_internal,ir.model.fields.help.tooltip,model_ir_model_fields_help_tooltip,base.group_user,1,0,0,0 |
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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_field |
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,30 @@ | ||
# Copyright 2023 Komit - Cuong Nguyen Mtm | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.tests import common | ||
|
||
|
||
class TestField(common.SavepointCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super(TestField, cls).setUpClass() | ||
|
||
def test_field_description_help(self): | ||
contact_user_id_field = self.env["res.partner"]._fields["user_id"] | ||
self.assertEqual( | ||
contact_user_id_field._description_help(self.env), | ||
"The internal user in charge of this contact.", | ||
) | ||
contact_user_id_field_rec = self.env["ir.model.fields"].search( | ||
[ | ||
("model", "=", "res.partner"), | ||
("name", "=", "user_id"), | ||
], | ||
limit=1, | ||
) | ||
self.env["ir.model.fields.help.tooltip"].create( | ||
{"field_id": contact_user_id_field_rec.id, "help": "This is a test help."} | ||
) | ||
self.assertEqual( | ||
contact_user_id_field._description_help(self.env), "This is a test help." | ||
) |
86 changes: 86 additions & 0 deletions
86
web_tooltip_field/views/ir_model_fields_help_tooltip_view.xml
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,86 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- Copyright 2023 Komit - Cuong Nguyen Mtm | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record id="ir_model_fields_help_tooltip_view_tree" model="ir.ui.view"> | ||
<field name="name">ir.model.fields.help.tooltip.view.tree</field> | ||
<field name="model">ir.model.fields.help.tooltip</field> | ||
<field name="arch" type="xml"> | ||
<tree> | ||
<field name="model" /> | ||
<field name="field_id" /> | ||
<field name="help" /> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="ir_model_fields_help_tooltip_view_form" model="ir.ui.view"> | ||
<field name="name">ir.model.fields.help.tooltip.view.form</field> | ||
<field name="model">ir.model.fields.help.tooltip</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<sheet> | ||
<group> | ||
<group> | ||
<field name="field_id" /> | ||
<field name="help" /> | ||
</group> | ||
<group> | ||
<field name="model" /> | ||
</group> | ||
</group> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="ir_model_fields_help_tooltip_view_search" model="ir.ui.view"> | ||
<field name="name">ir.model.fields.help.tooltip.view.search</field> | ||
<field name="model">ir.model.fields.help.tooltip</field> | ||
<field name="arch" type="xml"> | ||
<search> | ||
<field name="field_id" /> | ||
<field name="help" /> | ||
<group expand="0" string="Group By..."> | ||
<filter | ||
string="Model" | ||
name="groupby_model" | ||
context="{'group_by': 'model'}" | ||
/> | ||
</group> | ||
</search> | ||
</field> | ||
</record> | ||
|
||
<record id="ir_model_fields_help_tooltip_action" model="ir.actions.act_window"> | ||
<field name="name">Fields Help Tooltip</field> | ||
<field name="res_model">ir.model.fields.help.tooltip</field> | ||
<field name="view_mode">tree,form</field> | ||
<field name="view_id" ref="ir_model_fields_help_tooltip_view_tree" /> | ||
<field name="search_view_id" ref="ir_model_fields_help_tooltip_view_search" /> | ||
</record> | ||
|
||
<menuitem | ||
id="ir_model_fields_help_tooltip_menu" | ||
name="Fields Help Tooltip" | ||
parent="base.next_id_9" | ||
action="ir_model_fields_help_tooltip_action" | ||
sequence="15" | ||
/> | ||
|
||
<!-- Change sequence of other menu to place ir_model_fields_help_tooltip_menu in the middle --> | ||
<record id="base.ir_model_constraint_menu" model="ir.ui.menu"> | ||
<field name="sequence">20</field> | ||
</record> | ||
<record id="base.ir_model_relation_menu" model="ir.ui.menu"> | ||
<field name="sequence">25</field> | ||
</record> | ||
<record id="base.menu_action_attachment" model="ir.ui.menu"> | ||
<field name="sequence">30</field> | ||
</record> | ||
<record id="base.ir_logging_all_menu" model="ir.ui.menu"> | ||
<field name="sequence">35</field> | ||
</record> | ||
|
||
</odoo> |