diff --git a/help_contextual_popup/README.rst b/help_contextual_popup/README.rst new file mode 100644 index 00000000..3a59725e --- /dev/null +++ b/help_contextual_popup/README.rst @@ -0,0 +1,35 @@ +Add contextual help popup +========================= + +This module add a contextual html help popup on each model action. +You also may use dedicated field custom_help on actions to add specific help + +Installation +============ + +It was tested on Odoo 8.0 branch. + +Credits +======= + +Akretion + +Contributors +------------ + +* Sylvain Calador +* David Beal + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit http://odoo-community.org. + diff --git a/help_contextual_popup/__init__.py b/help_contextual_popup/__init__.py new file mode 100644 index 00000000..9186ee3a --- /dev/null +++ b/help_contextual_popup/__init__.py @@ -0,0 +1 @@ +from . import model diff --git a/help_contextual_popup/__openerp__.py b/help_contextual_popup/__openerp__.py new file mode 100644 index 00000000..6a50b045 --- /dev/null +++ b/help_contextual_popup/__openerp__.py @@ -0,0 +1,40 @@ +# coding: utf-8 +############################################################################## +# +# Odoo, Open Source Management Solution +# Copyright (C) 2015-TODAY Akretion (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'Help Contextual Popup', + 'version': '0.1', + 'author': 'Akretion, Odoo Community Association (OCA)', + 'depends': [ + 'web', + ], + 'demo': [], + 'website': 'https://www.akretion.com', + 'data': [ + 'views/popup_help_view.xml', + 'views/action_view.xml', + ], + 'qweb': [ + 'static/src/xml/popup_help.xml', + ], + 'installable': True, + 'auto_install': False, +} diff --git a/help_contextual_popup/model.py b/help_contextual_popup/model.py new file mode 100644 index 00000000..6674dec8 --- /dev/null +++ b/help_contextual_popup/model.py @@ -0,0 +1,31 @@ +# coding: utf-8 +############################################################################## +# +# Odoo, Open Source Management Solution +# Copyright (C) 2015-TODAY Akretion (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, fields + + +class IrActionsActwindow(models.Model): + _inherit = 'ir.actions.act_window' + + custom_help = fields.Text( + string="Custom Help", + help="Use this field to add custom content for documentation purpose") + diff --git a/help_contextual_popup/static/src/js/popup_help.js b/help_contextual_popup/static/src/js/popup_help.js new file mode 100644 index 00000000..b8882364 --- /dev/null +++ b/help_contextual_popup/static/src/js/popup_help.js @@ -0,0 +1,43 @@ +openerp.help_contextual_popup = function(instance, local) { + + var _t = instance.web._t; + instance.web.ViewManager.include({ + + do_create_view: function(view_type) { + var self = this; + var res = self._super(view_type); + self.$el.find('span.view_help').each(function () { + var $elem = $(this); + if ($elem.data('click-init')) { + return true; + } + $elem.data('click-init', true); + + var help_html = ''; + if (self.action.help) { + help_html += '

Odoo Help

' + help_html += '
' + self.action.help + '
'; + } + if (self.action.custom_help) { + help_html += '

Specific Help

' + help_html += '
' + self.action.custom_help + '
' + } + + $elem.on('click', function(e) { + + new instance.web.Dialog(self, { + size: 'medium', + title: _t("Help: ") + self.action.name, + buttons: [ + {text: _t("Ok"), click: function() { this.parents('.modal').modal('hide');}} + ] + }, help_html).open(); // self.action.res_model + }); + + return true; + + }); + return res; + }, + }); +} diff --git a/help_contextual_popup/static/src/xml/popup_help.xml b/help_contextual_popup/static/src/xml/popup_help.xml new file mode 100644 index 00000000..0467d6ca --- /dev/null +++ b/help_contextual_popup/static/src/xml/popup_help.xml @@ -0,0 +1,8 @@ + + + + + ? + + + diff --git a/help_contextual_popup/views/action_view.xml b/help_contextual_popup/views/action_view.xml new file mode 100644 index 00000000..df9098d2 --- /dev/null +++ b/help_contextual_popup/views/action_view.xml @@ -0,0 +1,17 @@ + + + + + + ir.actions.act_window + + + + + + + + + + diff --git a/help_contextual_popup/views/popup_help_view.xml b/help_contextual_popup/views/popup_help_view.xml new file mode 100644 index 00000000..1449ad20 --- /dev/null +++ b/help_contextual_popup/views/popup_help_view.xml @@ -0,0 +1,10 @@ + + + + + +