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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

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.

    +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.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.esm.js b/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.esm.js new file mode 100644 index 000000000..f6eb184bc --- /dev/null +++ b/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.esm.js @@ -0,0 +1,86 @@ +/** @odoo-module */ + +import {Component, markup} from "@odoo/owl"; + +import {FormViewDialog} from "@web/views/view_dialogs/form_view_dialog"; +import {session} from "@web/session"; +import {usePopover} from "@web/core/popover/popover_hook"; +import {useService} from "@web/core/utils/hooks"; + +export class FieldTooltipPopover extends Component {} +FieldTooltipPopover.template = "web_field_tooltip.FieldTooltipPopover"; + +export class FieldTooltip extends Component { + setup() { + this.popover = usePopover(); + this.tooltipPopover = null; + this.hasFieldTooltip = this.props.hasFieldTooltip; + this.canManageTooltip = session.can_manage_tooltips; + this.showAddHelper = + session.can_manage_tooltips && session.tooltip_show_add_helper; + this.fieldTooltip = this.props.field.field_tooltip; + + if (session.can_manage_tooltips) { + this.dialogService = useService("dialog"); + } + } + + get tooltipInfo() { + const props = this.props; + return { + title: props.field.string, + help: markup(this.tooltipText), + }; + } + + get tooltipText() { + return this.fieldTooltip.tooltip_text; + } + + onClickTooltip(e) { + e.preventDefault(); + e.stopPropagation(); + if (!this.canManageTooltip) { + return; + } + const tooltipId = (this.fieldTooltip && this.fieldTooltip.id) || false; + this.dialogService.add(FormViewDialog, { + resModel: "ir.model.fields.tooltip", + resId: tooltipId, + context: { + default_model: this.props.resModel, + default_field_name: this.props.fieldName, + }, + }); + } + + onMouseEnter(ev) { + if (!this.hasFieldTooltip) { + return; + } + this.closeTooltip(); + this.tooltipPopover = this.popover.add( + ev.currentTarget, + FieldTooltipPopover, + this.tooltipInfo, + { + closeOnClickAway: true, + position: "top", + title: "title", + } + ); + } + + onMouseLeave() { + this.closeTooltip(); + } + + closeTooltip() { + if (this.tooltipPopover) { + this.tooltipPopover(); + this.tooltipPopover = null; + } + } +} + +FieldTooltip.template = "web_field_tooltip.FieldTooltip"; diff --git a/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.scss b/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.scss new file mode 100644 index 000000000..0eb4788d2 --- /dev/null +++ b/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.scss @@ -0,0 +1,35 @@ +sup.field-tooltip { + .tooltip-icon { + background: none; + border: none; + display: inline-block; + width: fit-content; + margin-left: 0px; + + &[has-tooltip] { + color: #666666 !important; + } + } + + &:hover { + cursor: pointer; + } +} + +.popup-div { + min-width: 100px; + min-height: 30px; + + > * { + padding: 5px; + } + + .popover-title { + font-weight: bold; + background-color: #f7f7f7; + } + + .popover-content { + background-color: white; + } +} diff --git a/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.xml b/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.xml new file mode 100644 index 000000000..4ab68c328 --- /dev/null +++ b/web_field_tooltip/static/src/components/field_tooltip/field_tooltip.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + diff --git a/web_field_tooltip/static/src/css/web_field_tooltip.css b/web_field_tooltip/static/src/css/web_field_tooltip.css deleted file mode 100644 index b2fea36f2..000000000 --- a/web_field_tooltip/static/src/css/web_field_tooltip.css +++ /dev/null @@ -1,23 +0,0 @@ -sup.field-tooltip { - margin-right: 5px; -} - -sup.field-tooltip:hover { - cursor: pointer; -} - -.tooltip-icon { - color: #666666; - background: none; - border: none; - display: inline-block; - width: 0; - font-size: 12px; - margin-left: 0px; -} - -.popover-footer { - margin: 0; - padding: 8px 14px; - background-color: #f7f7f7; -} diff --git a/web_field_tooltip/static/src/js/controller.js b/web_field_tooltip/static/src/js/controller.js deleted file mode 100644 index 49f82e99f..000000000 --- a/web_field_tooltip/static/src/js/controller.js +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2023 ACSONE SA/NV - Copyright 2019 TODAY Serpent Consulting Services Pvt. Ltd. - License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ - -odoo.define("web_field_tooltip.controller", function(require) { - "use strict"; - - const FormController = require("web.FormController"); - const ListController = require("web.ListController"); - const tooltips = require("web_field_tooltip.FieldTooltip"); - - const core = require("web.core"); - const session = require("web.session"); - const _t = core._t; - - ListController.include( - Object.assign({}, tooltips.TooltipController, { - custom_events: _.extend({}, ListController.prototype.custom_events, { - add_tooltip: "_onAddTooltip", - edit_tooltip: "_onEditTooltip", - }), - }) - ); - - FormController.include( - Object.assign({}, tooltips.TooltipController, { - custom_events: _.extend({}, FormController.prototype.custom_events, { - add_tooltip: "_onAddTooltip", - edit_tooltip: "_onEditTooltip", - }), - - renderSidebar: function($node) { - this._super($node); - if (this.sidebar && session.can_manage_tooltips) { - this.sidebar.items.other.push({ - label: _t("Manage Tooltips"), - callback: this.on_manage_tooltips, - }); - } - }, - on_manage_tooltips: function() { - const self = this; - return self.do_action({ - type: "ir.actions.act_window", - name: _t("Manage Tooltips"), - res_model: "ir.model.fields.tooltip", - target: "current", - views: [ - [false, "list"], - [false, "form"], - ], - view_mode: "list", - domain: [["model", "=", self.modelName]], - context: {tooltip_model: self.modelName}, - }); - }, - }) - ); -}); diff --git a/web_field_tooltip/static/src/js/renderer.js b/web_field_tooltip/static/src/js/renderer.js deleted file mode 100644 index 95fbf1267..000000000 --- a/web_field_tooltip/static/src/js/renderer.js +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2023 ACSONE SA/NV - Copyright 2019 TODAY Serpent Consulting Services Pvt. Ltd. - License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ - -odoo.define("web_field_tooltip.renderer", function(require) { - "use strict"; - - const FormRenderer = require("web.FormRenderer"); - const ListRenderer = require("web.ListRenderer"); - const tooltips = require("web_field_tooltip.FieldTooltip"); - - FormRenderer.include( - Object.assign({}, tooltips.TooltipRenderer, { - init: function() { - this._super.apply(this, arguments); - this.tooltips = undefined; - }, - - /** - * @override - */ - _renderTagLabel: function(node) { - const self = this; - const $result = this._super.apply(this, arguments); - const fieldName = - node.tag === "label" ? node.attrs.for : node.attrs.name; - if (!fieldName) { - return $result; - } - self.add_tooltip($result, node); - - return $result; - }, - }) - ); - - ListRenderer.include( - Object.assign({}, tooltips.TooltipRenderer, { - init: function() { - this._super.apply(this, arguments); - this.tooltips = undefined; - }, - - /** - * @override - */ - _renderHeaderCell: function(node) { - const self = this; - const $result = this._super.apply(this, arguments); - const fieldName = - node.tag === "label" ? node.attrs.for : node.attrs.name; - if (!fieldName) { - return $result; - } - self.add_tooltip($result, node); - - return $result; - }, - }) - ); -}); diff --git a/web_field_tooltip/static/src/js/web_field_tooltip.js b/web_field_tooltip/static/src/js/web_field_tooltip.js deleted file mode 100644 index 06c732bda..000000000 --- a/web_field_tooltip/static/src/js/web_field_tooltip.js +++ /dev/null @@ -1,189 +0,0 @@ -/* Copyright 2023 ACSONE SA/NV - Copyright 2019 TODAY Serpent Consulting Services Pvt. Ltd. - License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ - -odoo.define("web_field_tooltip.FieldTooltip", function(require) { - "use strict"; - - const core = require("web.core"); - const dialogs = require("web.view_dialogs"); - const field_utils = require("web.field_utils"); - const rpc = require("web.rpc"); - const session = require("web.session"); - const _t = core._t; - - const TooltipRenderer = { - add_tooltip: function($result, node) { - const self = this; - const tooltip_title = $result.text(); - - const fieldName = node.tag === "label" ? node.attrs.for : node.attrs.name; - if (!fieldName) { - return $result; - } - - // Check if there's any tooltip that must be rendered for the given view - if (!self.tooltips) { - self.load_tooltips(); - } - - self.$tooltip_promise.then(function() { - let $tooltip = null; - let allow_add_tooltip_helper = - session.tooltip_show_add_helper && session.can_manage_tooltips; - _.each(self.tooltips, function(tooltip) { - if (tooltip.field_name === fieldName) { - $tooltip = self.get_tooltip_elem( - fieldName, - tooltip_title, - tooltip - ); - $result.append($tooltip); - allow_add_tooltip_helper = false; - } - }); - if (allow_add_tooltip_helper) { - $result.append(self.get_add_tooltip_elem(fieldName)); - } - }); - }, - - load_tooltips: function() { - const self = this; - self.$tooltip_promise = rpc - .query({ - model: "ir.model.fields.tooltip", - method: "search_read", - domain: [["model", "=", self.state.model]], - }) - .then(function(result) { - self.tooltips = result; - }); - }, - - get_add_tooltip_elem: function(fieldName) { - const self = this; - const $after_elem = $("", { - class: "fa fa fa-question-circle tooltip-icon text-info", - }); - - $after_elem.on("click", function(e) { - e.preventDefault(); - e.stopPropagation(); - self.trigger_up("add_tooltip", { - context: { - default_model: self.state.model, - default_field_name: fieldName, - }, - }); - }); - const $sup = $("", { - class: "field-tooltip", - }); - $sup.append($after_elem); - return $sup; - }, - - get_tooltip_elem: function(fieldName, tooltip_title, tooltip) { - const self = this; - const $after_elem = $("", { - class: "fa fa fa-question-circle tooltip-icon", - tabIndex: 0, - }); - - const $popup_div = $("
", { - class: "popup-div", - }); - - const $popup_text = $("

", { - html: tooltip.tooltip_text, - }); - - $popup_div.append($popup_text); - - if (session.can_manage_tooltips) { - const $popup_last_edit = $("

", { - class: "popover-footer", - html: - _t("Last Updated by: ") + - field_utils.format.many2one(tooltip.write_uid), - }); - - const $edit_button = $("