diff --git a/help_online/__init__.py b/help_online/__init__.py new file mode 100644 index 00000000..1a365a2d --- /dev/null +++ b/help_online/__init__.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Authors: Nemry Jonathan +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 . import controllers +from . import models diff --git a/help_online/__openerp__.py b/help_online/__openerp__.py new file mode 100644 index 00000000..178078b3 --- /dev/null +++ b/help_online/__openerp__.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Authors: Nemry Jonathan +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 Online', + 'version': '1.0', + 'author': 'ACSONE SA/NV', + 'maintainer': 'ACSONE SA/NV', + 'website': 'http://www.acsone.eu', + 'category': 'Documentation', + 'depends': [ + 'base', + 'website', + ], + 'description': """ +Help Online +=========== + +This module allows the creation of an online help available from the lists +and forms in Odoo. + +When loading a view, the module generates a button allowing access to an help +page for the related model if the page exists and the user is member of the +group 'Help reader'. If the page doesn't exist and the user is member of +the group 'Help writer', the module generate a button allowing the creation an +help page. + +The help pages are created and managed via the website Module. + """, + 'data': [ + 'security/help_online_groups.xml', + 'views/help_online_view.xml', + 'views/website_help_online.xml', + ], + 'qweb': [ + 'static/src/xml/help_online.xml', + ], + 'installable': True, + 'auto_install': False, +} diff --git a/help_online/controllers/__init__.py b/help_online/controllers/__init__.py new file mode 100644 index 00000000..8422fc0d --- /dev/null +++ b/help_online/controllers/__init__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Authors: Laurent Mignon +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 .import help_online_controllers diff --git a/help_online/controllers/help_online_controllers.py b/help_online/controllers/help_online_controllers.py new file mode 100644 index 00000000..70545d17 --- /dev/null +++ b/help_online/controllers/help_online_controllers.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Authors: Mignon Laurent +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 . +# +############################################################################## + +import openerp.http as http +from openerp.http import request + + +class HelpOnlineController(http.Controller): + + @http.route('/help_online/build_url', type='json', auth='user') + def build_url(self, model, view_type, domain=None, context=None): + help_online_model = request.env['help.online'] + return help_online_model.get_page_url( + model, view_type, domain=None, context=None) diff --git a/help_online/models/__init__.py b/help_online/models/__init__.py new file mode 100644 index 00000000..454eb497 --- /dev/null +++ b/help_online/models/__init__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Authors: Nemry Jonathan +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 . import help_online diff --git a/help_online/models/help_online.py b/help_online/models/help_online.py new file mode 100644 index 00000000..7400e38c --- /dev/null +++ b/help_online/models/help_online.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Authors: Laurent Mignon +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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.osv import orm +from openerp.tools.translate import _ + + +class HelpOnline(orm.TransientModel): + _name = 'help.online' + + def _get_view_name(self, model, view_type, domain=None, context=None): + name = 'help-%s' % model.replace('.', '-') + return name + + def page_exists(self, name): + website_model = self.env['website'] + return website_model.page_exists(name) + + def get_page_url(self, model, view_type, domain=None, context=None): + user_model = self.env['res.users'] + if not user_model.has_group('help_online.help_online_group_reader'): + return {} + ir_model = self.env['ir.model'] + description = self.env[model]._description + res = ir_model.name_search(model, operator='=') + if(res): + description = res[0][1] + name = self._get_view_name(model, view_type, domain, context) + if self.page_exists(name): + url = '/page/%s' % name + if view_type: + url = url + '#' + view_type + title = _('Help on %s') % description + return {'url': url, + 'title': title, + 'exists': True} + elif user_model.has_group('help_online.help_online_group_writer'): + title = _('Create Help page for %s') % description + return {'url': 'website/add/%s' % name, + 'title': title, + 'exists': False} + else: + return {} diff --git a/help_online/security/help_online_groups.xml b/help_online/security/help_online_groups.xml new file mode 100644 index 00000000..fd981bf1 --- /dev/null +++ b/help_online/security/help_online_groups.xml @@ -0,0 +1,16 @@ + + + + Help reader + + + + Help writer + + + + + \ No newline at end of file diff --git a/help_online/static/description/help_online_create_page.png b/help_online/static/description/help_online_create_page.png new file mode 100644 index 00000000..eb97a45a Binary files /dev/null and b/help_online/static/description/help_online_create_page.png differ diff --git a/help_online/static/description/help_online_view_page.png b/help_online/static/description/help_online_view_page.png new file mode 100644 index 00000000..07def9f9 Binary files /dev/null and b/help_online/static/description/help_online_view_page.png differ diff --git a/help_online/static/description/index.html b/help_online/static/description/index.html new file mode 100644 index 00000000..e2edb627 --- /dev/null +++ b/help_online/static/description/index.html @@ -0,0 +1,16 @@ +
+
+

Help Online

+

This module allows the creation of an online help available from the lists and forms in Odoo.

+

When loading a view, the module generates a button allowing access to an help + page for the related model if the page exists and the user is member of the + group 'Help reader'.

+ help_online_view_page.png +

If the page doesn't exist and the user is member of + the group 'Help writer', the module generate a button allowing the creation an + help page.

+ help_online_create_page.png +

The help pages are created and managed via the website Module.

+
+
+
diff --git a/help_online/static/src/css/help_online.css b/help_online/static/src/css/help_online.css new file mode 100644 index 00000000..90134d99 --- /dev/null +++ b/help_online/static/src/css/help_online.css @@ -0,0 +1,12 @@ +li.oe_help_online_not_found { + background-color: red; +} + +.openerp .oe_view_manager .oe_view_manager_switch .oe_list_button_help_online:after { + font-size: 28px; + content: "?"; + text-align: center; + margin: 3px auto 4px; + position: relative; + display: block; +} diff --git a/help_online/static/src/js/help_online.js b/help_online/static/src/js/help_online.js new file mode 100644 index 00000000..c660a110 --- /dev/null +++ b/help_online/static/src/js/help_online.js @@ -0,0 +1,115 @@ +openerp.help_online = function (instance) { + var QWeb = instance.web.qweb; + var _t = instance.web._t; + var _lt = instance.web._lt; + + instance.web.ListView.include({ + load_list: function () { + var self = this; + var add_button = false; + if (!this.$buttons) { + add_button = true; + } + this._super.apply(this, arguments); + this.$buttons.on('click', '.oe_list_button_help_online', function() { + self.do_action({ + type: 'ir.actions.act_url', + url: '/partner_mobile', + target: 'self', + }); + }); + }, + }); + + openerp.web.TreeView.include({ + view_loading: function(r) { + var ret = this._super(r); + if(! _.isUndefined(this.ViewManager.load_help_buttons)){ + this.ViewManager.load_help_buttons(); + } + return ret + }, + }); + + openerp.web.ListView.include({ + view_loading: function(r) { + var ret = this._super(r); + if(! _.isUndefined(this.ViewManager.load_help_buttons)){ + this.ViewManager.load_help_buttons(); + } + return ret + }, + }); + + openerp.web.FormView.include({ + view_loading: function(r) { + var ret = this._super(r); + if(!_.isUndefined(this.ViewManager.clean_help_buttons)){ + this.ViewManager.clean_help_buttons(); + } + return ret + }, + + do_show: function (options){ + var ret = this._super(options); + if(! _.isUndefined(this.ViewManager.load_help_buttons)){ + this.ViewManager.load_help_buttons(); + } + return ret + }, + }); + + openerp.web.ViewManager.include({ + clean_help_buttons:function() { + this.$el.find("div.oe_help_online_buttons").first().remove(); + }, + + load_help_buttons:function() { + var self = this; + this.rpc('/help_online/build_url', {model: this.dataset.model, view_type: this.active_view}).then(function(result) { + self.clean_help_buttons(); + if (result && ! _.isEmpty(result)) { + self.$helpButtonsEl = $(QWeb.render("HelpOnline.Buttons", {'view_manager':self, 'url_info': result})); + self.$el.find("ul.oe_view_manager_switch.oe_button_group.oe_right").first().before(self.$helpButtonsEl); + self.$helpButtonsEl.find('a.oe_list_button_help_online').tooltip(); + if (result.exists === false) { + self.$helpButtonsEl.find('li').addClass('oe_help_online_not_found') + self.$helpButtonsEl.find('a.oe_list_button_help_online').on('click', function (event) { + var evt = event; + evt.preventDefault(); + var dialog = new instance.web.Dialog(this, { + title: _t('Confirm'), + buttons: [ + {text: _t("Cancel"), click: function() { + this.parents('.modal').modal('hide'); + return false; + } + }, + {text: _t("Ok"), click: function() { + this.parents('.modal').modal('hide'); + var form = $("
"); + form.attr( + { + id : "formform", + // The location given in the link itself + action : evt.target.href, + method : "GET", + // Open in new window/tab + target : evt.target.target + }); + $("body").append(form); + $("#formform").submit(); + $("#formform").remove(); + return false; + } + } + ], + }, $('
').text(_t('Page does not exist. Do you want to create?'))).open(); + }); + } + } + }); + }, + + }); +} diff --git a/help_online/static/src/js/website_help_online.editor.js b/help_online/static/src/js/website_help_online.editor.js new file mode 100644 index 00000000..0dc2f3d1 --- /dev/null +++ b/help_online/static/src/js/website_help_online.editor.js @@ -0,0 +1,21 @@ +(function () { + 'use strict'; + + var website = openerp.website; + var _t = openerp._t; + website.RTE.include({ + _config: function () { + // add anchor button + var config = this._super(); + config.plugins = config.plugins.concat(',link'); + _.each(config.toolbar, function (tb) { + if (tb.name === 'span'){ + tb.items.unshift('Anchor'); + } + }); + return config; + }, + }); +})(); + + diff --git a/help_online/static/src/xml/help_online.xml b/help_online/static/src/xml/help_online.xml new file mode 100644 index 00000000..fb55b85b --- /dev/null +++ b/help_online/static/src/xml/help_online.xml @@ -0,0 +1,13 @@ + + +
+
    +
  • + +
  • +
+
+
+
diff --git a/help_online/views/help_online_view.xml b/help_online/views/help_online_view.xml new file mode 100644 index 00000000..c53cbce3 --- /dev/null +++ b/help_online/views/help_online_view.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/help_online/views/website_help_online.xml b/help_online/views/website_help_online.xml new file mode 100644 index 00000000..353d82e6 --- /dev/null +++ b/help_online/views/website_help_online.xml @@ -0,0 +1,12 @@ + + + + + + + +