Browse Source
Merge pull request #40 from acsone/add-help_online
Merge pull request #40 from acsone/add-help_online
[ADD] Module help_onlinepull/60/head
Pedro M. Baeza
10 years ago
16 changed files with 431 additions and 0 deletions
-
22help_online/__init__.py
-
57help_online/__openerp__.py
-
21help_online/controllers/__init__.py
-
32help_online/controllers/help_online_controllers.py
-
21help_online/models/__init__.py
-
60help_online/models/help_online.py
-
16help_online/security/help_online_groups.xml
-
BINhelp_online/static/description/help_online_create_page.png
-
BINhelp_online/static/description/help_online_view_page.png
-
16help_online/static/description/index.html
-
12help_online/static/src/css/help_online.css
-
115help_online/static/src/js/help_online.js
-
21help_online/static/src/js/website_help_online.editor.js
-
13help_online/static/src/xml/help_online.xml
-
13help_online/views/help_online_view.xml
-
12help_online/views/website_help_online.xml
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Authors: Nemry Jonathan |
||||
|
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from . import controllers |
||||
|
from . import models |
@ -0,0 +1,57 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Authors: Nemry Jonathan |
||||
|
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
{ |
||||
|
'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, |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Authors: Laurent Mignon |
||||
|
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from .import help_online_controllers |
@ -0,0 +1,32 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Authors: Laurent Mignon |
||||
|
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
|
||||
|
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=domain, context=context) |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Authors: Nemry Jonathan |
||||
|
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from . import help_online |
@ -0,0 +1,60 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Authors: Laurent Mignon |
||||
|
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
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 {} |
@ -0,0 +1,16 @@ |
|||||
|
<openerp> |
||||
|
<data> |
||||
|
<record id="help_online_group_reader" model="res.groups"> |
||||
|
<field name="name">Help reader</field> |
||||
|
<field name="category_id" ref="base.module_category_documentation"/> |
||||
|
</record> |
||||
|
<record id="help_online_group_writer" model="res.groups"> |
||||
|
<field name="name">Help writer</field> |
||||
|
<field name="category_id" ref="base.module_category_documentation"/> |
||||
|
<field name="implied_ids" eval="[ |
||||
|
(4, ref('help_online_group_reader')), |
||||
|
(4, ref('base.group_website_publisher')), |
||||
|
]"/> |
||||
|
</record> |
||||
|
</data> |
||||
|
</openerp> |
After Width: 971 | Height: 541 | Size: 53 KiB |
After Width: 971 | Height: 601 | Size: 86 KiB |
@ -0,0 +1,16 @@ |
|||||
|
<div class="document"> |
||||
|
<div class="section" id="help-online"> |
||||
|
<h1>Help Online</h1> |
||||
|
<p>This module allows the creation of an online help available from the lists and forms in Odoo.</p> |
||||
|
<p>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'.</p> |
||||
|
<img alt="help_online_view_page.png" src="help_online_view_page.png" width="80%" height="80%"/> |
||||
|
<p>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.</p> |
||||
|
<img alt="help_online_create_page.png" src="help_online_create_page.png" width="80%" height="80%"/> |
||||
|
<p>The help pages are created and managed via the website Module.</p> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</div> |
@ -0,0 +1,12 @@ |
|||||
|
li.oe_help_online_not_found { |
||||
|
background-color: #df3f3f; |
||||
|
} |
||||
|
|
||||
|
.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; |
||||
|
} |
@ -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></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; |
||||
|
} |
||||
|
} |
||||
|
], |
||||
|
}, $('<div/>').text(_t('Page does not exist. Do you want to create?'))).open(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
}, |
||||
|
|
||||
|
}); |
||||
|
} |
@ -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; |
||||
|
}, |
||||
|
}); |
||||
|
})(); |
||||
|
|
||||
|
|
@ -0,0 +1,13 @@ |
|||||
|
<templates> |
||||
|
<t t-name='HelpOnline.Buttons'> |
||||
|
<div class='oe_help_online_buttons'> |
||||
|
<ul class='oe_view_manager_switch oe_button_group oe_right'> |
||||
|
<li class='oe_i'> |
||||
|
<a class='oe_list_button_help_online' |
||||
|
t-att-title='url_info.title' |
||||
|
t-att-href='url_info.url' target='_blank'></a> |
||||
|
</li> |
||||
|
</ul> |
||||
|
</div> |
||||
|
</t> |
||||
|
</templates> |
@ -0,0 +1,13 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- vim:fdn=3: |
||||
|
--> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
<template id="assets_backend" name="help.online.assets" inherit_id="web.assets_backend"> |
||||
|
<xpath expr="." position="inside"> |
||||
|
<link rel="stylesheet" href="/help_online/static/src/css/help_online.css" type="text/css"/> |
||||
|
<script type="text/javascript" src="/help_online/static/src/js/help_online.js"></script> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
</data> |
||||
|
</openerp> |
@ -0,0 +1,12 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<template id="head" inherit_id="website.layout" name="Help online customization"> |
||||
|
<xpath expr="//head" position="inside"> |
||||
|
<script type="text/javascript" src="/help_online/static/src/js/website_help_online.editor.js" groups="base.group_website_publisher"></script> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue