From e729006a1949011bd18e80573d88a1bd50969ba7 Mon Sep 17 00:00:00 2001
From: Benjamin Willig
Date: Tue, 26 Mar 2024 08:52:09 +0100
Subject: [PATCH] [MIG] web_field_tooltip: Migration to 16.0
---
.../odoo/addons/web_field_tooltip | 1 +
setup/web_field_tooltip/setup.py | 6 +
web_field_tooltip/README.rst | 15 +-
web_field_tooltip/__manifest__.py | 15 +-
web_field_tooltip/models/__init__.py | 1 +
web_field_tooltip/models/base.py | 29 +++
.../models/ir_model_fields_tooltip.py | 12 +-
web_field_tooltip/models/res_users.py | 16 +-
web_field_tooltip/readme/DESCRIPTION.rst | 3 +-
.../static/description/index.html | 11 +-
.../field_tooltip/field_tooltip.esm.js | 86 ++++++++
.../field_tooltip/field_tooltip.scss | 35 ++++
.../field_tooltip/field_tooltip.xml | 29 +++
.../static/src/css/web_field_tooltip.css | 23 ---
web_field_tooltip/static/src/js/controller.js | 59 ------
web_field_tooltip/static/src/js/renderer.js | 61 ------
.../static/src/js/web_field_tooltip.js | 189 ------------------
.../src/views/form/form_controller.esm.js | 34 ++++
.../static/src/views/form/form_label.esm.js | 34 ++++
.../static/src/views/form/form_label.xml | 17 ++
.../src/views/list/list_renderer.esm.js | 36 ++++
.../static/src/views/list/list_renderer.xml | 28 +++
.../tests/test_web_field_tooltip.py | 8 +-
.../views/ir_model_fields_tooltip.xml | 26 ++-
24 files changed, 402 insertions(+), 372 deletions(-)
create mode 120000 setup/web_field_tooltip/odoo/addons/web_field_tooltip
create mode 100644 setup/web_field_tooltip/setup.py
create mode 100644 web_field_tooltip/models/base.py
create mode 100644 web_field_tooltip/static/src/components/field_tooltip/field_tooltip.esm.js
create mode 100644 web_field_tooltip/static/src/components/field_tooltip/field_tooltip.scss
create mode 100644 web_field_tooltip/static/src/components/field_tooltip/field_tooltip.xml
delete mode 100644 web_field_tooltip/static/src/css/web_field_tooltip.css
delete mode 100644 web_field_tooltip/static/src/js/controller.js
delete mode 100644 web_field_tooltip/static/src/js/renderer.js
delete mode 100644 web_field_tooltip/static/src/js/web_field_tooltip.js
create mode 100644 web_field_tooltip/static/src/views/form/form_controller.esm.js
create mode 100644 web_field_tooltip/static/src/views/form/form_label.esm.js
create mode 100644 web_field_tooltip/static/src/views/form/form_label.xml
create mode 100644 web_field_tooltip/static/src/views/list/list_renderer.esm.js
create mode 100644 web_field_tooltip/static/src/views/list/list_renderer.xml
diff --git a/setup/web_field_tooltip/odoo/addons/web_field_tooltip b/setup/web_field_tooltip/odoo/addons/web_field_tooltip
new file mode 120000
index 000000000..aa35a5cb6
--- /dev/null
+++ b/setup/web_field_tooltip/odoo/addons/web_field_tooltip
@@ -0,0 +1 @@
+../../../../web_field_tooltip
\ No newline at end of file
diff --git a/setup/web_field_tooltip/setup.py b/setup/web_field_tooltip/setup.py
new file mode 100644
index 000000000..28c57bb64
--- /dev/null
+++ b/setup/web_field_tooltip/setup.py
@@ -0,0 +1,6 @@
+import setuptools
+
+setuptools.setup(
+ setup_requires=['setuptools-odoo'],
+ odoo_addon=True,
+)
diff --git a/web_field_tooltip/README.rst b/web_field_tooltip/README.rst
index fe4af44d3..2a94e2111 100644
--- a/web_field_tooltip/README.rst
+++ b/web_field_tooltip/README.rst
@@ -7,7 +7,7 @@ Web Field Tooltip
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! source digest: sha256:546620e49e8a51bd4af1d867397642b2810a3e7a0d30f39c06cd7d8454a96c43
+ !! source digest: sha256:6a4fafacb03368529d861e303732dce4c182ee511090cb4fd9ca04d67347bae0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,20 +17,19 @@ Web Field Tooltip
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
- :target: https://github.com/OCA/web/tree/13.0/web_field_tooltip
+ :target: https://github.com/OCA/web/tree/16.0/web_field_tooltip
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_field_tooltip
+ :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_field_tooltip
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
- :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=13.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module gives the possibility to add tooltips next to fields labels on any
-field of a model. The tooltip displays an html field that can contain links and
-the name of the user that last updated it.
+field of a model. The tooltip displays an html field.
**Table of contents**
@@ -65,7 +64,7 @@ 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 to smash it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -95,6 +94,6 @@ 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.
-This module is part of the `OCA/web `_ project on GitHub.
+This module is part of the `OCA/web `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/web_field_tooltip/__manifest__.py b/web_field_tooltip/__manifest__.py
index 5e37d5290..93fc08581 100644
--- a/web_field_tooltip/__manifest__.py
+++ b/web_field_tooltip/__manifest__.py
@@ -6,7 +6,7 @@
"name": "Web Field Tooltip",
"summary": """
Displays customizable tooltips for fields""",
- "version": "13.0.1.0.0",
+ "version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
@@ -16,6 +16,17 @@
"security/ir_model_access.xml",
"views/ir_model_fields_tooltip.xml",
"views/res_users.xml",
- "views/template.xml",
],
+ "assets": {
+ "web.assets_backend": [
+ "/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.esm.js",
+ "/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.scss",
+ "/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.xml",
+ "/web_field_tooltip/static/src/views/form/form_controller.esm.js",
+ "/web_field_tooltip/static/src/views/form/form_label.esm.js",
+ "/web_field_tooltip/static/src/views/form/form_label.xml",
+ "/web_field_tooltip/static/src/views/list/list_renderer.esm.js",
+ "/web_field_tooltip/static/src/views/list/list_renderer.xml",
+ ],
+ },
}
diff --git a/web_field_tooltip/models/__init__.py b/web_field_tooltip/models/__init__.py
index 99736d12e..a5c939c73 100644
--- a/web_field_tooltip/models/__init__.py
+++ b/web_field_tooltip/models/__init__.py
@@ -1,3 +1,4 @@
+from . import base
from . import ir_http
from . import ir_model_fields_tooltip
from . import res_users
diff --git a/web_field_tooltip/models/base.py b/web_field_tooltip/models/base.py
new file mode 100644
index 000000000..c272a7329
--- /dev/null
+++ b/web_field_tooltip/models/base.py
@@ -0,0 +1,29 @@
+# Copyright 2023 ACSONE SA/NV
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+
+from odoo import api, models
+
+
+class Base(models.AbstractModel):
+ _inherit = "base"
+
+ @api.model
+ def fields_get(self, allfields=None, attributes=None):
+ res = super().fields_get(allfields=allfields, attributes=attributes)
+ fnames = res.keys()
+ tooltips_data = (
+ self.env["ir.model.fields.tooltip"]
+ .sudo()
+ .search_read(
+ [
+ ("model", "=", self._name),
+ ("field_name", "in", list(fnames)),
+ ],
+ [],
+ )
+ )
+ for tooltip_data in tooltips_data:
+ tooltip_fname = tooltip_data["field_name"]
+ res[tooltip_fname]["field_tooltip"] = tooltip_data
+ return res
diff --git a/web_field_tooltip/models/ir_model_fields_tooltip.py b/web_field_tooltip/models/ir_model_fields_tooltip.py
index 42e1bf8a3..cda060e31 100644
--- a/web_field_tooltip/models/ir_model_fields_tooltip.py
+++ b/web_field_tooltip/models/ir_model_fields_tooltip.py
@@ -18,20 +18,24 @@ class IrModelFieldsTooltip(models.Model):
help="Model for the Field Tooltip.",
default=lambda self: self._get_default_model_id(),
)
- model = fields.Char(related="model_id.model", string="Model Name")
+ model = fields.Char(related="model_id.model", string="Model Name", store=True)
field_id = fields.Many2one(
string="Field",
required=True,
comodel_name="ir.model.fields",
ondelete="cascade",
)
- name = fields.Char(compute="_compute_name", readonly=True,)
+ field_name = fields.Char(related="field_id.name", store=True)
+ name = fields.Char(
+ compute="_compute_name",
+ readonly=True,
+ )
active = fields.Boolean(
default=True,
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", required=True)
+ tooltip_text = fields.Html(required=True)
@api.model
def default_get(self, fields_list):
@@ -61,7 +65,7 @@ class IrModelFieldsTooltip(models.Model):
raise UserError(_("A tooltip already exists for this field"))
def _get_default_model_id(self):
- tooltip_model = self.env.context.get("tooltip_model")
+ tooltip_model = self.env.context.get("default_model")
model = self.env["ir.model"].search([("model", "=", tooltip_model)], limit=1)
return model.id or False
diff --git a/web_field_tooltip/models/res_users.py b/web_field_tooltip/models/res_users.py
index 3b44b9c94..7796da9aa 100644
--- a/web_field_tooltip/models/res_users.py
+++ b/web_field_tooltip/models/res_users.py
@@ -16,11 +16,17 @@ class ResUsers(models.Model):
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)
+ @property
+ def TOOLTIP_READABLE_FIELDS(self):
+ return ["tooltip_show_add_helper"]
+
+ @property
+ def SELF_READABLE_FIELDS(self):
+ return super().SELF_READABLE_FIELDS + self.TOOLTIP_READABLE_FIELDS
+
+ @property
+ def SELF_WRITEABLE_FIELDS(self):
+ return super().SELF_WRITEABLE_FIELDS + self.TOOLTIP_READABLE_FIELDS
def _compute_tooltip_show_add_helper_allowed(self):
for rec in self:
diff --git a/web_field_tooltip/readme/DESCRIPTION.rst b/web_field_tooltip/readme/DESCRIPTION.rst
index 84bf1c5e6..413722111 100644
--- a/web_field_tooltip/readme/DESCRIPTION.rst
+++ b/web_field_tooltip/readme/DESCRIPTION.rst
@@ -1,3 +1,2 @@
This module gives the possibility to add tooltips next to fields labels on any
-field of a model. The tooltip displays an html field that can contain links and
-the name of the user that last updated it.
+field of a model. The tooltip displays an html field.
diff --git a/web_field_tooltip/static/description/index.html b/web_field_tooltip/static/description/index.html
index 455ddb578..31cf2edd5 100644
--- a/web_field_tooltip/static/description/index.html
+++ b/web_field_tooltip/static/description/index.html
@@ -367,12 +367,11 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!! source digest: sha256:546620e49e8a51bd4af1d867397642b2810a3e7a0d30f39c06cd7d8454a96c43
+!! source digest: sha256:6a4fafacb03368529d861e303732dce4c182ee511090cb4fd9ca04d67347bae0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This module gives the possibility to add tooltips next to fields labels on any
-field of a model. The tooltip displays an html field that can contain links and
-the name of the user that last updated it.
+field of a model. The tooltip displays an html field.
Table of contents
@@ -413,7 +412,7 @@ on a field as some fields are not displayed with a label.
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 to smash it by providing a detailed and welcomed
-feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -437,7 +436,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
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.
-
This module is part of the OCA/web project on GitHub.
+
This module is part of the OCA/web project on GitHub.