@ -0,0 +1,50 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg |
||||
|
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html |
||||
|
:alt: License: LGPL-3 |
||||
|
|
||||
|
Dynamic Hover on Related Fields |
||||
|
=============================== |
||||
|
Dynamic Hover on Related Fields Helps you to show the configured |
||||
|
fields in a tooltip popup |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
No additional configuration required |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
General Public License, Version 3 (LGPL v3). |
||||
|
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developer: (V18) Ayana KP, |
||||
|
(V17) ASWIN A K, |
||||
|
Contact: odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if |
||||
|
your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Ayana KP (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import models |
@ -0,0 +1,59 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Ayana KP (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
{ |
||||
|
'name': 'Dynamic Hover on Related Fields', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Extra Tools', |
||||
|
'summary': 'Dynamic Hover on Related Fields Helps you to ' |
||||
|
'show the configured fields in a tooltip popup', |
||||
|
'description': 'Enhance your user experience with ' |
||||
|
'Dynamic Hover on Related Fields! This feature allows ' |
||||
|
'you to effortlessly display configured fields in ' |
||||
|
'a convenient tooltip popup. You have the flexibility ' |
||||
|
'to choose which fields and models you want to showcase ' |
||||
|
'when hovering over relevant information. ' |
||||
|
'Simplify your interactions and access key data with ease.', |
||||
|
'author': 'Cybrosys Techno solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': "https://www.cybrosys.com", |
||||
|
'depends': ['web'], |
||||
|
'data': [ |
||||
|
'security/ir.model.access.csv', |
||||
|
'views/hover_related_fields_views.xml' |
||||
|
], |
||||
|
'assets': { |
||||
|
'web.assets_backend': [ |
||||
|
'dynamic_hover_on_related_fields/static/src/xml/listRenderer.xml', |
||||
|
'dynamic_hover_on_related_fields/static/src/xml/many2OneField.xml', |
||||
|
'dynamic_hover_on_related_fields/static/src/xml/relatedFieldTooltip.xml', |
||||
|
'dynamic_hover_on_related_fields/static/src/xml/tagsList.xml', |
||||
|
'dynamic_hover_on_related_fields/static/src/xml/webFieldToltip.xml', |
||||
|
'dynamic_hover_on_related_fields/static/src/js/*.js', |
||||
|
], |
||||
|
}, |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'LGPL-3', |
||||
|
'installable': True, |
||||
|
'application': True, |
||||
|
'auto_install': False, |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
## Module <dynamic_hover_on_related_fields> |
||||
|
|
||||
|
#### 13.12.2024 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
#### ADD |
||||
|
- Initial Commit for Dynamic Hover on Related Fields |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Ayana KP (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import hover_related_fields |
@ -0,0 +1,121 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Ayana KP (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class HoverRelatedFields(models.Model): |
||||
|
""" |
||||
|
Model for managing hover-related fields and their configurations. |
||||
|
""" |
||||
|
_name = 'hover.related.fields' |
||||
|
_description = 'Hover Related Fields' |
||||
|
_rec_name = 'model_id' |
||||
|
_sql_constraints = [ |
||||
|
('unique_model_id', 'UNIQUE(model_id)', |
||||
|
'One model should only have one configuration.') |
||||
|
] |
||||
|
|
||||
|
model_ids = fields.Many2many( |
||||
|
'ir.model', |
||||
|
'hover_related_models_rel', |
||||
|
string='Models', |
||||
|
compute='_compute_model_ids', |
||||
|
help='Models related to the configuration ' |
||||
|
'for setting domain for model_id', |
||||
|
) |
||||
|
model_id = fields.Many2one( |
||||
|
'ir.model', |
||||
|
'Model', |
||||
|
domain="[('id', 'not in', model_ids)]", |
||||
|
help='Select a model for configuration', |
||||
|
) |
||||
|
field_ids = fields.Many2many( |
||||
|
'ir.model.fields', |
||||
|
string='Fields', domain="[('model_id', '=', model_id)]", |
||||
|
help='Fields related to the selected model', |
||||
|
) |
||||
|
active = fields.Boolean( |
||||
|
string='Active', |
||||
|
default=True, |
||||
|
help='Helps to archive the configurations') |
||||
|
|
||||
|
@api.depends('model_id') |
||||
|
def _compute_model_ids(self): |
||||
|
self.model_ids = self.search([]).mapped('model_id') |
||||
|
|
||||
|
@api.model |
||||
|
def finding_the_data_to_show_tooltip(self, info): |
||||
|
""" |
||||
|
Method to find data to display in tooltips based on the provided |
||||
|
information. |
||||
|
|
||||
|
:param info: Information about the tooltip request. |
||||
|
:type info: dict |
||||
|
:return: Data to display in the tooltip. |
||||
|
:rtype: list or bool |
||||
|
""" |
||||
|
current_record = self.env[info['resModel']].browse(int(info['resId'])) |
||||
|
field_name = info['field']['name'] |
||||
|
configured_model = self.search( |
||||
|
[('model_id.model', '=', info['field']['relation'])]) |
||||
|
required_data = [[ |
||||
|
{ |
||||
|
'id': field.id, |
||||
|
'field': field.field_description, |
||||
|
'field_name': field.name, |
||||
|
'ttype': field.ttype, |
||||
|
'value': rec[ |
||||
|
field.name |
||||
|
].display_name if field.ttype == 'many2one' else rec[field.name] |
||||
|
} for field in configured_model.field_ids |
||||
|
] for rec in current_record[field_name]] |
||||
|
return required_data if required_data != [[]] else False |
||||
|
|
||||
|
@api.model |
||||
|
def finding_the_data_to_show_tooltip_many2many(self, info): |
||||
|
""" |
||||
|
Method to find data for tooltips in many2many, |
||||
|
many2one relationships. |
||||
|
|
||||
|
:param info: Information about the tooltip request. |
||||
|
:type info: dict |
||||
|
:return: Data to display in the tooltip. |
||||
|
:rtype: list or string |
||||
|
""" |
||||
|
rec_to_show = self.env[info['field']['relation']].browse( |
||||
|
int(info['related_record_id'])) |
||||
|
configured_model = self.search( |
||||
|
[('model_id.model', '=', info['field']['relation'])]) |
||||
|
required_data = [ |
||||
|
{ |
||||
|
'id': field.id, |
||||
|
'field': field.field_description, |
||||
|
'field_name': field.name, |
||||
|
'ttype': field.ttype, |
||||
|
'value': rec_to_show[ |
||||
|
field.name |
||||
|
].display_name if field.ttype == 'many2one' else rec_to_show[field.name] |
||||
|
} |
||||
|
for field in configured_model.field_ids] |
||||
|
if required_data == [] and info['viewMode'] == 'list': |
||||
|
required_data = rec_to_show.display_name |
||||
|
return required_data |
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 767 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 760 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 697 KiB |
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 160 KiB |
After Width: | Height: | Size: 110 KiB |
After Width: | Height: | Size: 97 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 139 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 736 KiB |
After Width: | Height: | Size: 36 KiB |
@ -0,0 +1,33 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
|
||||
|
export function getTooltipInfo(params) { |
||||
|
let widgetDescription = undefined; |
||||
|
if (params.fieldInfo.widget) { |
||||
|
widgetDescription = params.fieldInfo.field.displayName; |
||||
|
} |
||||
|
|
||||
|
const info = { |
||||
|
viewMode: params.viewMode, |
||||
|
resModel: params.resModel, |
||||
|
resId: params.resId, |
||||
|
debug: Boolean(odoo.debug), |
||||
|
field: { |
||||
|
name: params.field.name, |
||||
|
help: params.fieldInfo.help ?? params.field.help, |
||||
|
type: params.field.type, |
||||
|
widget: params.fieldInfo.widget, |
||||
|
widgetDescription, |
||||
|
context: params.fieldInfo.context, |
||||
|
domain: params.fieldInfo.domain || params.field.domain, |
||||
|
invisible: params.fieldInfo.invisible, |
||||
|
column_invisible: params.fieldInfo.column_invisible, |
||||
|
readonly: params.fieldInfo.readonly, |
||||
|
required: params.fieldInfo.required, |
||||
|
changeDefault: params.field.change_default, |
||||
|
relation: params.field.relation, |
||||
|
selection: params.field.selection, |
||||
|
default: params.field.default, |
||||
|
}, |
||||
|
}; |
||||
|
return JSON.stringify(info); |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
|
||||
|
import { FormLabel } from "@web/views/form/form_label" |
||||
|
import { patch } from "@web/core/utils/patch" |
||||
|
import { getTooltipInfo } from "./fieldToltip" |
||||
|
patch(FormLabel.prototype, { |
||||
|
/** |
||||
|
* Retrieves tooltip information for the FormLabel. |
||||
|
* @returns {string} JSON string representing tooltip information. |
||||
|
*/ |
||||
|
get tooltipInfo() { |
||||
|
if (!odoo.debug) { |
||||
|
return JSON.stringify({ |
||||
|
field: { |
||||
|
help: this.tooltipHelp, |
||||
|
}, |
||||
|
}); |
||||
|
} |
||||
|
return getTooltipInfo({ |
||||
|
viewMode: "form", |
||||
|
resModel: this.props.record.resModel, |
||||
|
resId: this.props.record.resId, |
||||
|
field: this.props.record.fields[this.props.fieldName], |
||||
|
fieldInfo: this.props.fieldInfo, |
||||
|
help: this.tooltipHelp, |
||||
|
}); |
||||
|
}, |
||||
|
}) |
@ -0,0 +1,29 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
|
||||
|
import { patch } from "@web/core/utils/patch" |
||||
|
import { ListRenderer } from "@web/views/list/list_renderer"; |
||||
|
|
||||
|
patch(ListRenderer.prototype, { |
||||
|
/** |
||||
|
* Generates tooltip information for the ListRenderer. |
||||
|
* @returns {string} JSON string representing tooltip information. |
||||
|
*/ |
||||
|
tolTipInfo(record, fields) { |
||||
|
const field = record.fields[fields.name] |
||||
|
const info = { |
||||
|
viewMode: "list", |
||||
|
resModel: record.resModel, |
||||
|
related_record_id: record.data[fields.name][0], |
||||
|
resId: record.resId, |
||||
|
debug: Boolean(odoo.debug), |
||||
|
field: { |
||||
|
name: field.name, |
||||
|
help: field?.help, |
||||
|
type: field.type, |
||||
|
domain: field.domain, |
||||
|
relation: field.relation, |
||||
|
}, |
||||
|
}; |
||||
|
return JSON.stringify(info); |
||||
|
} |
||||
|
}) |
@ -0,0 +1,44 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
|
||||
|
import { patch } from "@web/core/utils/patch"; |
||||
|
import { Many2ManyTagsField } from "@web/views/fields/many2many_tags/many2many_tags_field"; |
||||
|
|
||||
|
patch(Many2ManyTagsField.prototype, { |
||||
|
|
||||
|
/** |
||||
|
* Retrieves tag properties for the Many2ManyTagsField. |
||||
|
* @param {Object} record - The record for which tag properties are retrieved. |
||||
|
* @returns {Object} Tag properties object. |
||||
|
*/ |
||||
|
getTagProps(record) { |
||||
|
const field = this.props.record.fields[this.props.name] |
||||
|
const info = { |
||||
|
viewMode: "form", |
||||
|
resModel:this.props.record.resModel, |
||||
|
resId: this.props.record.resId, |
||||
|
related_record_id: record.resId, |
||||
|
debug: Boolean(odoo.debug), |
||||
|
field: { |
||||
|
name: field.name, |
||||
|
help: field?.help, |
||||
|
type: field.type, |
||||
|
domain: field.domain, |
||||
|
relation: field.relation, |
||||
|
}, |
||||
|
}; |
||||
|
return { |
||||
|
id: record.id, // datapoint_X
|
||||
|
resId: record.resId, |
||||
|
text: record.data.display_name, |
||||
|
colorIndex: record.data[this.props.colorField], |
||||
|
onDelete: !this.props.readonly ? () => this.deleteTag(record.id) : undefined, |
||||
|
onKeydown: (ev) => { |
||||
|
if (this.props.readonly) { |
||||
|
return; |
||||
|
} |
||||
|
this.onTagKeydown(ev); |
||||
|
}, |
||||
|
info: JSON.stringify(info) |
||||
|
}; |
||||
|
} |
||||
|
}) |
@ -0,0 +1,51 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
|
||||
|
import { patch } from "@web/core/utils/patch"; |
||||
|
import { Many2OneField } from "@web/views/fields/many2one/many2one_field"; |
||||
|
|
||||
|
patch(Many2OneField.prototype, { |
||||
|
/** |
||||
|
* Generates tooltip information for the Many2OneField. |
||||
|
* @returns {string} JSON string representing tooltip information. |
||||
|
*/ |
||||
|
get tooltipInfo() { |
||||
|
return this.getTooltipInfo({ |
||||
|
viewMode: "form", |
||||
|
resModel: this.props.record.resModel, |
||||
|
related_record_id: this.props.record.data[this.props.name][0], |
||||
|
resId: this.props.record.resId, |
||||
|
field: this.props.record.fields[this.props.name], |
||||
|
fieldInfo: this.props.fieldInfo, |
||||
|
}); |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Constructs tooltip information object based on provided parameters. |
||||
|
* @param {Object} params - Parameters for tooltip information. |
||||
|
* @param {string} params.viewMode - View mode of the record. |
||||
|
* @param {string} params.resModel - Model of the record. |
||||
|
* @param {number} params.resId - ID of the record. |
||||
|
* @param {Object} params.field - Field information. |
||||
|
* @param {Object} params.fieldInfo - Field information. |
||||
|
* @returns {string} JSON string representing tooltip information. |
||||
|
*/ |
||||
|
getTooltipInfo(params){ |
||||
|
const info = { |
||||
|
viewMode: params.viewMode, |
||||
|
resModel: params.resModel, |
||||
|
related_record_id: params.related_record_id, |
||||
|
resId: params.resId, |
||||
|
debug: Boolean(odoo.debug), |
||||
|
field: { |
||||
|
name: params.field.name, |
||||
|
help: params.field?.help, |
||||
|
type: params.field.type, |
||||
|
domain: params.field.domain, |
||||
|
relation: params.field.relation, |
||||
|
}, |
||||
|
}; |
||||
|
console.log('info',info) |
||||
|
return JSON.stringify(info); |
||||
|
}, |
||||
|
}) |
@ -0,0 +1,40 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
|
||||
|
import { patch } from "@web/core/utils/patch" |
||||
|
//import { PopoverController } from "@web/core/popover/popover_controller";
|
||||
|
import { onWillStart } from "@odoo/owl"; |
||||
|
import { useService } from "@web/core/utils/hooks"; |
||||
|
import { usePopover } from "@web/core/popover/popover_hook"; |
||||
|
import { Popover } from "@web/core/popover/popover"; |
||||
|
console.log('Popover',Popover) |
||||
|
|
||||
|
const PopoverProps = { |
||||
|
setup(){ |
||||
|
this.orm = useService("orm"); |
||||
|
onWillStart(async () => await this.getDataFromBackend()); |
||||
|
super.setup(); |
||||
|
}, |
||||
|
/** |
||||
|
* Fetches data from the backend to display in tooltips. |
||||
|
* Determines whether to call the method for many2many relationships or regular fields. |
||||
|
* Updates the required data in the component props. |
||||
|
*/ |
||||
|
async getDataFromBackend() { |
||||
|
if (!this.props.componentProps?.info?.field?.relation) return |
||||
|
if (this.props.componentProps?.info?.related_record_id){ |
||||
|
const requiredData = await this.orm.call( |
||||
|
"hover.related.fields", |
||||
|
"finding_the_data_to_show_tooltip_many2many", |
||||
|
[this?.props?.componentProps?.info]); |
||||
|
|
||||
|
this.props.componentProps.info.requiredData = requiredData; |
||||
|
}else if(this.props.componentProps?.info?.resId){ |
||||
|
const requiredData = await this.orm.call( |
||||
|
"hover.related.fields", |
||||
|
"finding_the_data_to_show_tooltip", |
||||
|
[this?.props?.componentProps?.info]); |
||||
|
this.props.componentProps.info.requiredData = requiredData; |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
patch(Popover.prototype, PopoverProps); |
@ -0,0 +1,33 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<templates xml:space="preserve"> |
||||
|
<!-- |
||||
|
This template inherits the `web.ListRenderer.RecordRow` template and adds |
||||
|
some data attributes to the td tag that are required for the tooltip. |
||||
|
--> |
||||
|
<t t-inherit="web.ListRenderer.RecordRow" t-inherit-mode="extension"> |
||||
|
<td t-on-keydown="(ev) => this.onCellKeydown(ev, group, record)" |
||||
|
class="o_data_cell cursor-pointer" |
||||
|
t-att-class="this.getCellClass(column, record)" |
||||
|
t-att-name="column.name" |
||||
|
t-att-colspan="column.colspan" |
||||
|
t-att-data-tooltip="!isInvisible ? getCellTitle(column, record) : false" |
||||
|
data-tooltip-delay="1000" |
||||
|
t-on-click="(ev) => this.onCellClicked(record, column, ev)" tabindex="-1" position="replace"> |
||||
|
<td t-on-keydown="(ev) => this.onCellKeydown(ev, group, record)" |
||||
|
class="o_data_cell cursor-pointer" |
||||
|
t-att-class="getCellClass(column, record)" |
||||
|
t-att-name="column.name" |
||||
|
t-att-colspan="column.colspan" |
||||
|
t-att-data-tooltip="!isInvisible ? getCellTitle(column, record) : false" |
||||
|
t-att-data-tooltip-info="['Many2OneField', 'SaleOrderLineProductField'].includes(column.field.component.name)? tolTipInfo(record, column): false" |
||||
|
t-att-data-tooltip-template="['Many2OneField', 'SaleOrderLineProductField'].includes(column.field.component.name)? 'dynamic_hover_on_related_fields.RelatedFieldTooltip' : false" |
||||
|
data-tooltip-delay="1000" |
||||
|
t-on-click="(ev) => this.onCellClicked(record, column, ev)" tabindex="-1"> |
||||
|
<t t-if="!isInvisible"> |
||||
|
<t t-if="canUseFormatter(column, record)" t-out="getFormattedValue(column, record)"/> |
||||
|
<Field t-else="" name="column.name" record="record" type="column.widget" class="getFieldClass(column)" fieldInfo="column" t-props="getFieldProps(record, column)"/> |
||||
|
</t> |
||||
|
</td> |
||||
|
</td> |
||||
|
</t> |
||||
|
</templates> |
@ -0,0 +1,63 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<templates xml:space="preserve"> |
||||
|
<!-- This template extends the behavior of the web.Many2OneField component. |
||||
|
It modifies and added the data attribute required for tooltip based on certain conditions. --> |
||||
|
<t t-inherit="web.Many2OneField" t-inherit-mode="extension"> |
||||
|
<t t-if="!props.canOpen" position="replace"> |
||||
|
<t t-if="!props.canOpen"> |
||||
|
<span> |
||||
|
<span t-esc="displayName" |
||||
|
t-att="{'data-tooltip-template': 'dynamic_hover_on_related_fields.RelatedFieldTooltip', 'data-tooltip-info': tooltipInfo, 'data-tooltip-touch-tap-to-show': 'true'}"/> |
||||
|
<t t-foreach="extraLines" t-as="extraLine" t-key="extraLine_index"> |
||||
|
<br /> |
||||
|
<span t-esc="extraLine" /> |
||||
|
</t> |
||||
|
</span> |
||||
|
</t> |
||||
|
</t> |
||||
|
<a t-if="value" t-attf-class="o_form_uri #{classFromDecoration}" t-on-click.prevent="onClick" position="replace"> |
||||
|
<t t-log="'value',value"/> |
||||
|
<a t-if="value" |
||||
|
t-attf-class="o_form_uri #{classFromDecoration}" |
||||
|
t-on-click.prevent="onClick" |
||||
|
t-att="{'data-tooltip-template': 'dynamic_hover_on_related_fields.RelatedFieldTooltip', 'data-tooltip-info': tooltipInfo, 'data-tooltip-touch-tap-to-show': 'true'}"> |
||||
|
<t t-log="'extraLines',extraLines"/> |
||||
|
<span t-esc="displayName" /> |
||||
|
<t t-log="'displayName',displayName"/> |
||||
|
<t t-foreach="extraLines" t-as="extraLine" t-key="extraLine_index"> |
||||
|
<br /> |
||||
|
<span t-esc="extraLine" /> |
||||
|
</t> |
||||
|
</a> |
||||
|
</a> |
||||
|
<div class="o_field_many2one_selection" position="replace"> |
||||
|
<div class="o_field_many2one_selection" |
||||
|
t-att="{'data-tooltip-template': 'dynamic_hover_on_related_fields.RelatedFieldTooltip', 'data-tooltip-info': tooltipInfo, 'data-tooltip-touch-tap-to-show': 'true'}"> |
||||
|
<Many2XAutocomplete t-props="Many2XAutocompleteProps"/> |
||||
|
<t t-if="hasExternalButton"> |
||||
|
<button |
||||
|
type="button" |
||||
|
class="btn btn-link text-action oi o_external_button" |
||||
|
t-att-class="env.inDialog ? 'oi-launch' : 'oi-arrow-right'" |
||||
|
tabindex="-1" |
||||
|
draggable="false" |
||||
|
aria-label="Internal link" |
||||
|
data-tooltip="Internal link" |
||||
|
t-on-click="onExternalBtnClick" |
||||
|
/> |
||||
|
</t> |
||||
|
<button |
||||
|
t-if="hasBarcodeButton" |
||||
|
t-on-click="onBarcodeBtnClick" |
||||
|
type="button" |
||||
|
class="btn ms-3 o_barcode" |
||||
|
tabindex="-1" |
||||
|
draggable="false" |
||||
|
aria-label="Scan barcode" |
||||
|
title="Scan barcode" |
||||
|
data-tooltip="Scan barcode" |
||||
|
/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</t> |
||||
|
</templates> |