diff --git a/web_shortcuts/LICENSE b/web_shortcut/LICENSE similarity index 100% rename from web_shortcuts/LICENSE rename to web_shortcut/LICENSE diff --git a/web_shortcut/README.rst b/web_shortcut/README.rst new file mode 100644 index 00000000..3e4ae7c9 --- /dev/null +++ b/web_shortcut/README.rst @@ -0,0 +1,61 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============= +Shortcut Menu +============= + +Adds a button to the top menu which opens a menu containing the user's shortcuts. + +Configuration +============= + +To configure this module, you need to: + +#. Go to any view; +#. click on the star icon besides the title to add / remove a shortcut. + +Usage +===== + +To use this module, you need to: + +#. Click on the star icon in the right corner of the top menu; +#. click the shortcut you want. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/162/9.0 + +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 smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Adrien Peiffer +* Dennis Sluijk + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://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 https://odoo-community.org. \ No newline at end of file diff --git a/web_shortcuts/__init__.py b/web_shortcut/__init__.py similarity index 97% rename from web_shortcuts/__init__.py rename to web_shortcut/__init__.py index 0c453b00..aa9b673b 100644 --- a/web_shortcuts/__init__.py +++ b/web_shortcut/__init__.py @@ -18,4 +18,4 @@ # ############################################################################## -from . import model +from . import models diff --git a/web_shortcuts/__openerp__.py b/web_shortcut/__openerp__.py similarity index 82% rename from web_shortcuts/__openerp__.py rename to web_shortcut/__openerp__.py index e9c28d98..0c44ac58 100644 --- a/web_shortcuts/__openerp__.py +++ b/web_shortcut/__openerp__.py @@ -19,18 +19,23 @@ # ############################################################################## { - 'name': 'Web Shortcuts', - 'version': '8.0.1.0.0', - 'category': 'Tools', + 'name': 'Shortcut Menu', + 'version': '9.0.1.0.0', + 'category': 'Web', 'author': "OpenERP SA,Odoo Community Association (OCA)", 'website': 'http://openerp.com', - 'depends': ['base'], + 'depends': [ + 'base', + 'web' + ], 'data': [ 'security/ir.model.access.csv', - 'view/web_shortcuts.xml', - ], - 'qweb': ['static/src/xml/web_shortcuts.xml'], - 'installable': False, + 'templates/assets.xml', + ], + 'qweb': [ + 'static/src/xml/web_shortcut.xml' + ], + 'installable': True, 'auto_install': False, } diff --git a/web_shortcuts/i18n/ar.po b/web_shortcut/i18n/ar.po similarity index 100% rename from web_shortcuts/i18n/ar.po rename to web_shortcut/i18n/ar.po diff --git a/web_shortcuts/i18n/bs.po b/web_shortcut/i18n/bs.po similarity index 100% rename from web_shortcuts/i18n/bs.po rename to web_shortcut/i18n/bs.po diff --git a/web_shortcuts/i18n/cs.po b/web_shortcut/i18n/cs.po similarity index 100% rename from web_shortcuts/i18n/cs.po rename to web_shortcut/i18n/cs.po diff --git a/web_shortcuts/i18n/da.po b/web_shortcut/i18n/da.po similarity index 100% rename from web_shortcuts/i18n/da.po rename to web_shortcut/i18n/da.po diff --git a/web_shortcuts/i18n/de.po b/web_shortcut/i18n/de.po similarity index 100% rename from web_shortcuts/i18n/de.po rename to web_shortcut/i18n/de.po diff --git a/web_shortcuts/i18n/el.po b/web_shortcut/i18n/el.po similarity index 100% rename from web_shortcuts/i18n/el.po rename to web_shortcut/i18n/el.po diff --git a/web_shortcuts/i18n/en_GB.po b/web_shortcut/i18n/en_GB.po similarity index 100% rename from web_shortcuts/i18n/en_GB.po rename to web_shortcut/i18n/en_GB.po diff --git a/web_shortcuts/i18n/es.po b/web_shortcut/i18n/es.po similarity index 100% rename from web_shortcuts/i18n/es.po rename to web_shortcut/i18n/es.po diff --git a/web_shortcuts/i18n/fi.po b/web_shortcut/i18n/fi.po similarity index 100% rename from web_shortcuts/i18n/fi.po rename to web_shortcut/i18n/fi.po diff --git a/web_shortcuts/i18n/fr.po b/web_shortcut/i18n/fr.po similarity index 100% rename from web_shortcuts/i18n/fr.po rename to web_shortcut/i18n/fr.po diff --git a/web_shortcuts/i18n/gl.po b/web_shortcut/i18n/gl.po similarity index 100% rename from web_shortcuts/i18n/gl.po rename to web_shortcut/i18n/gl.po diff --git a/web_shortcuts/i18n/hr.po b/web_shortcut/i18n/hr.po similarity index 100% rename from web_shortcuts/i18n/hr.po rename to web_shortcut/i18n/hr.po diff --git a/web_shortcuts/i18n/hu.po b/web_shortcut/i18n/hu.po similarity index 100% rename from web_shortcuts/i18n/hu.po rename to web_shortcut/i18n/hu.po diff --git a/web_shortcuts/i18n/it.po b/web_shortcut/i18n/it.po similarity index 100% rename from web_shortcuts/i18n/it.po rename to web_shortcut/i18n/it.po diff --git a/web_shortcuts/i18n/lt.po b/web_shortcut/i18n/lt.po similarity index 100% rename from web_shortcuts/i18n/lt.po rename to web_shortcut/i18n/lt.po diff --git a/web_shortcuts/i18n/mk.po b/web_shortcut/i18n/mk.po similarity index 100% rename from web_shortcuts/i18n/mk.po rename to web_shortcut/i18n/mk.po diff --git a/web_shortcuts/i18n/mn.po b/web_shortcut/i18n/mn.po similarity index 100% rename from web_shortcuts/i18n/mn.po rename to web_shortcut/i18n/mn.po diff --git a/web_shortcuts/i18n/nl.po b/web_shortcut/i18n/nl.po similarity index 100% rename from web_shortcuts/i18n/nl.po rename to web_shortcut/i18n/nl.po diff --git a/web_shortcuts/i18n/pl.po b/web_shortcut/i18n/pl.po similarity index 100% rename from web_shortcuts/i18n/pl.po rename to web_shortcut/i18n/pl.po diff --git a/web_shortcuts/i18n/pt.po b/web_shortcut/i18n/pt.po similarity index 100% rename from web_shortcuts/i18n/pt.po rename to web_shortcut/i18n/pt.po diff --git a/web_shortcuts/i18n/pt_BR.po b/web_shortcut/i18n/pt_BR.po similarity index 100% rename from web_shortcuts/i18n/pt_BR.po rename to web_shortcut/i18n/pt_BR.po diff --git a/web_shortcuts/i18n/ro.po b/web_shortcut/i18n/ro.po similarity index 100% rename from web_shortcuts/i18n/ro.po rename to web_shortcut/i18n/ro.po diff --git a/web_shortcuts/i18n/ru.po b/web_shortcut/i18n/ru.po similarity index 100% rename from web_shortcuts/i18n/ru.po rename to web_shortcut/i18n/ru.po diff --git a/web_shortcuts/i18n/sl.po b/web_shortcut/i18n/sl.po similarity index 100% rename from web_shortcuts/i18n/sl.po rename to web_shortcut/i18n/sl.po diff --git a/web_shortcuts/i18n/sv.po b/web_shortcut/i18n/sv.po similarity index 100% rename from web_shortcuts/i18n/sv.po rename to web_shortcut/i18n/sv.po diff --git a/web_shortcuts/i18n/th.po b/web_shortcut/i18n/th.po similarity index 100% rename from web_shortcuts/i18n/th.po rename to web_shortcut/i18n/th.po diff --git a/web_shortcuts/i18n/tr.po b/web_shortcut/i18n/tr.po similarity index 100% rename from web_shortcuts/i18n/tr.po rename to web_shortcut/i18n/tr.po diff --git a/web_shortcuts/i18n/vi.po b/web_shortcut/i18n/vi.po similarity index 100% rename from web_shortcuts/i18n/vi.po rename to web_shortcut/i18n/vi.po diff --git a/web_shortcuts/i18n/web_shortcuts.pot b/web_shortcut/i18n/web_shortcuts.pot similarity index 100% rename from web_shortcuts/i18n/web_shortcuts.pot rename to web_shortcut/i18n/web_shortcuts.pot diff --git a/web_shortcuts/i18n/zh_CN.po b/web_shortcut/i18n/zh_CN.po similarity index 100% rename from web_shortcuts/i18n/zh_CN.po rename to web_shortcut/i18n/zh_CN.po diff --git a/web_shortcuts/i18n/zh_TW.po b/web_shortcut/i18n/zh_TW.po similarity index 100% rename from web_shortcuts/i18n/zh_TW.po rename to web_shortcut/i18n/zh_TW.po diff --git a/web_shortcuts/model/__init__.py b/web_shortcut/models/__init__.py similarity index 100% rename from web_shortcuts/model/__init__.py rename to web_shortcut/models/__init__.py diff --git a/web_shortcuts/model/web_shortcut.py b/web_shortcut/models/web_shortcut.py similarity index 100% rename from web_shortcuts/model/web_shortcut.py rename to web_shortcut/models/web_shortcut.py diff --git a/web_shortcuts/security/ir.model.access.csv b/web_shortcut/security/ir.model.access.csv similarity index 100% rename from web_shortcuts/security/ir.model.access.csv rename to web_shortcut/security/ir.model.access.csv diff --git a/web_shortcuts/static/description/icon.png b/web_shortcut/static/description/icon.png similarity index 100% rename from web_shortcuts/static/description/icon.png rename to web_shortcut/static/description/icon.png diff --git a/web_shortcuts/static/src/css/web_shortcuts.css b/web_shortcut/static/src/css/web_shortcut.css similarity index 100% rename from web_shortcuts/static/src/css/web_shortcuts.css rename to web_shortcut/static/src/css/web_shortcut.css diff --git a/web_shortcuts/static/src/img/add-shortcut.png b/web_shortcut/static/src/img/add-shortcut.png similarity index 100% rename from web_shortcuts/static/src/img/add-shortcut.png rename to web_shortcut/static/src/img/add-shortcut.png diff --git a/web_shortcut/static/src/js/web_shortcut.js b/web_shortcut/static/src/js/web_shortcut.js new file mode 100644 index 00000000..4c32aa3f --- /dev/null +++ b/web_shortcut/static/src/js/web_shortcut.js @@ -0,0 +1,159 @@ +/*############################################################################ +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011-2012 OpenERP SA (). +# +# 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 . +# +############################################################################*/ + +odoo.define('web.shortcut', function(require) { + var widget = require('web.Widget'), + menu = require('web.UserMenu'), + client = require('web.WebClient'), + view_manager = require('web.ViewManager'), + model = require('web.DataModel'); + + + var ShortcutMenu = widget.extend({ + template: 'Systray.ShortcutMenu', + init: function() { + this._super(); + this.on('load', this, this.load); + this.on('add', this, this.add); + this.on('display', this, this.display); + this.on('remove', this, this.remove); + this.model = new model('web.shortcut'); + }, + start: function() { + var self = this; + this._super(); + this.trigger('load'); + this.$el.on('click', '.oe_systray_shortcut_menu a', function() { + self.click($(this)); + }); + }, + load: function() { + var self = this; + this.$el.find('.oe_systray_shortcut_menu').empty(); + return this.model.call('get_user_shortcuts', [ + ]).done(function(shortcuts) { + _.each(shortcuts, function(sc) { + self.trigger('display', sc); + }); + }); + }, + add: function (sc) { + var self = this; + this.model.call('create', [sc]).then(function(out){ + self.trigger('load'); + }); + }, + display: function(sc) { + var self = this; + this.$el.find('.oe_systray_shortcut_menu').append(); + var $sc = $(QWeb.render('Systray.ShortcutMenu.Item', {'shortcut': sc})); + $sc.appendTo(self.$el.find('.oe_systray_shortcut_menu')); + }, + remove: function (menu_id) { + var menu_id = this.session.active_id; + var $shortcut = this.$el.find('.oe_systray_shortcut_menu li a[data-id=' + menu_id + ']'); + var shortcut_id = $shortcut.data('shortcut-id'); + $shortcut.remove(); + this.model.call('unlink', [shortcut_id]); + }, + click: function($link) { + var self = this, + action_id = $link.data('id'); + + new model('ir.ui.menu').query(['action']).filter([['id', '=', id]]).context(null).all().then(function(menu) { + var action_str = menu[0].action; + var action_str_parts = action_str.split(','); + action_id = parseInt(action_str_parts[1]); + self.trigger('click', action_id); + }); + }, + has: function(menu_id) { + return !!this.$el.find('a[data-id=' + menu_id + ']').length; + } + }); + + + menu.include({ + do_update: function() { + var self = this; + this._super.apply(this, arguments); + this.update_promise.done(function() { + if (self.shortcuts) { + self.shortcuts.trigger('load'); + } else { + self.shortcuts = new ShortcutMenu(self); + self.shortcuts.prependTo(self.$el.parent()); + } + }); + }, + }); + + + client.include({ + show_application: function() { + var self = this; + this._super.apply(this, arguments); + this.user_menu.on('click', this, function(action_id) { + self.do_action(action_id); + }); + } + }); + + + view_manager.include({ + switch_mode: function (view_type, no_store) { + var self = this; + this._super.apply(this, arguments).done(function() { + self.shortcut_check(self.views[view_type]); + }); + }, + shortcut_check: function(view) { + var self = this; + console.log(this); + var shortcuts_menu = this.action_manager.webclient.user_menu.shortcuts; + // display shortcuts if on the first view for the action + var $shortcut_toggle = this.$el.find('.oe_shortcut_toggle'); + if (!this.action.name || + !(view.view_type === this.view_stack[0].view_type + && view.view_id === this.view_stack[0].view_id)) { + $shortcut_toggle.hide(); + return; + } + // Anonymous users don't have user_menu + if (shortcuts_menu) { + $shortcut_toggle.toggleClass('oe_shortcut_remove', shortcuts_menu.has(self.session.active_id)); + $shortcut_toggle.unbind("click").click(function() { + if ($shortcut_toggle.hasClass("oe_shortcut_remove")) { + shortcuts_menu.trigger('remove', self.session.active_id); + } else { + shortcuts_menu.trigger('add', { + 'user_id': self.session.uid, + 'menu_id': self.session.active_id, + 'name': self.action.name + }); + } + $shortcut_toggle.toggleClass("oe_shortcut_remove"); + }); + } + } + }); + + return ShortcutMenu; +}); diff --git a/web_shortcut/static/src/xml/web_shortcut.xml b/web_shortcut/static/src/xml/web_shortcut.xml new file mode 100644 index 00000000..c471658f --- /dev/null +++ b/web_shortcut/static/src/xml/web_shortcut.xml @@ -0,0 +1,27 @@ + + + + + + + +
  • + + + +
  • +
    + + + + + +
    diff --git a/web_shortcut/templates/assets.xml b/web_shortcut/templates/assets.xml new file mode 100644 index 00000000..4fe95b3e --- /dev/null +++ b/web_shortcut/templates/assets.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/web_shortcuts/README.rst b/web_shortcuts/README.rst deleted file mode 100644 index e3e36f90..00000000 --- a/web_shortcuts/README.rst +++ /dev/null @@ -1,7 +0,0 @@ -Enable shortcuts feature in the web client. -=========================================== - -Add a Shortcut icon in the systray in order to access the user's shortcuts -(if any). - -Add a Shortcut icon besides the views title in order to add/remove a shortcut. \ No newline at end of file diff --git a/web_shortcuts/static/src/js/web_shortcuts.js b/web_shortcuts/static/src/js/web_shortcuts.js deleted file mode 100644 index 943def16..00000000 --- a/web_shortcuts/static/src/js/web_shortcuts.js +++ /dev/null @@ -1,150 +0,0 @@ -/*############################################################################ -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2011-2012 OpenERP SA (). -# -# 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 . -# -############################################################################*/ - -openerp.web_shortcuts = function (instance) { - -var QWeb = instance.web.qweb, - _t = instance.web._t; - -instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({ - template: 'Systray.Shortcuts', - - init: function() { - this._super(); - this.on('load', this, this.load); - this.on('add', this, this.add); - this.on('display', this, this.display); - this.on('remove', this, this.remove); - this.on('click', this, this.click); - this.model = new instance.web.Model('web.shortcut'); - }, - start: function() { - var self = this; - this._super(); - this.trigger('load'); - this.$el.on('click', '.oe_systray_shortcuts_items a', function() { - self.trigger('click', $(this)); - }); - }, - load: function() { - var self = this; - this.$el.find('.oe_systray_shortcuts_items').empty(); - return this.model.call('get_user_shortcuts', [ - instance.session.uid, - instance.web.pyeval.eval('context', {}) - ]).done(function(shortcuts) { - _.each(shortcuts, function(sc) { - self.trigger('display', sc); - }); - }); - }, - add: function (sc) { - var self = this; - this.model.call('create', [sc]).then(function(out){ - self.trigger('load'); - }); - }, - display: function(sc) { - var self = this; - this.$el.find('.oe_systray_shortcuts_items').append(); - var $sc = $(QWeb.render('Systray.Shortcuts.Item', {'shortcut': sc})); - $sc.appendTo(self.$el.find('.oe_systray_shortcuts_items')); - }, - remove: function (menu_id) { - var menu_id = this.session.active_id; - var $shortcut = this.$el.find('.oe_systray_shortcuts_items li a[data-id=' + menu_id + ']'); - var shortcut_id = $shortcut.data('shortcut-id'); - $shortcut.remove(); - this.model.call('unlink', [shortcut_id]); - }, - click: function($link) { - var self = this, - id = $link.data('id'); - self.session.active_id = id; - // TODO: Use do_action({menu_id: id, type: 'ir.actions.menu'}) - new instance.web.Model('ir.ui.menu').query(['action']).filter([['id', '=', id]]).context(null).all().then(function(menu) { - var action_str = menu[0].action; - var action_str_parts = action_str.split(','); - var action_id = parseInt(action_str_parts[1]) - self.rpc('/web/action/load', {'action_id': action_id}).done(function(action) { - instance.webclient.on_menu_action({action_id: action.id}); - }); - }); - this.$el.find('.oe_systray_shortcuts').trigger('mouseout'); - }, - has: function(menu_id) { - return !!this.$el.find('a[data-id=' + menu_id + ']').length; - } -}); - -instance.web.UserMenu.include({ - do_update: function() { - var self = this; - this._super.apply(this, arguments); - this.update_promise.done(function() { - if (self.shortcuts) { - self.shortcuts.trigger('load'); - } else { - self.shortcuts = new instance.web_shortcuts.Shortcuts(self); - self.shortcuts.appendTo(instance.webclient.$el.find('.oe_systray')); - } - }); - }, -}); - -instance.web.ViewManagerAction.include({ - switch_mode: function (view_type, no_store) { - var self = this; - this._super.apply(this, arguments).done(function() { - self.shortcut_check(self.views[view_type]); - }); - }, - shortcut_check : function(view) { - var self = this; - var shortcuts_menu = instance.webclient.user_menu.shortcuts; - var grandparent = this.getParent() && this.getParent().getParent(); - // display shortcuts if on the first view for the action - var $shortcut_toggle = this.$el.find('.oe_shortcuts_toggle'); - if (!this.action.name || - !(view.view_type === this.views_src[0].view_type - && view.view_id === this.views_src[0].view_id)) { - $shortcut_toggle.hide(); - return; - } - // Anonymous users don't have user_menu - if (shortcuts_menu) { - $shortcut_toggle.toggleClass('oe_shortcuts_remove', shortcuts_menu.has(self.session.active_id)); - $shortcut_toggle.unbind("click").click(function() { - if ($shortcut_toggle.hasClass("oe_shortcuts_remove")) { - shortcuts_menu.trigger('remove', self.session.active_id); - } else { - shortcuts_menu.trigger('add', { - 'user_id': self.session.uid, - 'menu_id': self.session.active_id, - 'name': self.action.name - }); - } - $shortcut_toggle.toggleClass("oe_shortcuts_remove"); - }); - } - } -}); - -}; diff --git a/web_shortcuts/static/src/xml/web_shortcuts.xml b/web_shortcuts/static/src/xml/web_shortcuts.xml deleted file mode 100644 index 1aa7a8cd..00000000 --- a/web_shortcuts/static/src/xml/web_shortcuts.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - -
  • - - - -
  • -
    - - - - - -
    diff --git a/web_shortcuts/view/web_shortcuts.xml b/web_shortcuts/view/web_shortcuts.xml deleted file mode 100644 index bd27657c..00000000 --- a/web_shortcuts/view/web_shortcuts.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - -