diff --git a/attachment_action/README.rst b/attachment_action/README.rst new file mode 100644 index 00000000..a4b442e0 --- /dev/null +++ b/attachment_action/README.rst @@ -0,0 +1,52 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +====================== +Actions on attachments +====================== + +This module was written to provide a container for other modules to add buttons for actions on attachments. + +Usage +===== + +This module does nothing useful on its own. + +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 +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Holger Brunn + +Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list `_ or the `appropriate specialized mailinglist `_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues. + +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. diff --git a/attachment_action/__init__.py b/attachment_action/__init__.py new file mode 100644 index 00000000..8c501711 --- /dev/null +++ b/attachment_action/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). diff --git a/attachment_action/__openerp__.py b/attachment_action/__openerp__.py new file mode 100644 index 00000000..2ab7d384 --- /dev/null +++ b/attachment_action/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Actions on attachments", + "version": "8.0.1.0.0", + "author": "Therp BV,Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Hidden/Dependency", + "summary": "Enable/disable actions on attachments", + "depends": [ + 'web', + 'knowledge', + 'document', + ], + "data": [ + 'views/templates.xml', + ], + "qweb": [ + 'static/src/xml/attachment_action.xml', + ], +} diff --git a/attachment_action/static/description/icon.png b/attachment_action/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/attachment_action/static/description/icon.png differ diff --git a/attachment_action/static/src/css/attachment_action.css b/attachment_action/static/src/css/attachment_action.css new file mode 100644 index 00000000..3caa01a0 --- /dev/null +++ b/attachment_action/static/src/css/attachment_action.css @@ -0,0 +1,37 @@ +.openerp .oe_sidebar .oe_dropdown_menu li span.oe_sidebar_attachment_action .oe_sidebar_delete_item +{ + position: static; +} +.openerp .oe_sidebar .oe_dropdown_menu li span.oe_sidebar_attachment_action +{ + display: none; + position: absolute; + right: 0; + top: 0; + left: 50%; + text-align: right; + padding: 0px 6px; +} +.openerp .oe_sidebar .oe_dropdown_menu li span.oe_sidebar_attachment_action > * +{ + display: inline-block; + padding: 2px; + color: #8786b7; + font-weight: bold; + text-shadow: 0 1px 1px white; + margin-right: 1px; +} +.openerp .oe_sidebar .oe_dropdown_menu li span.oe_sidebar_attachment_action > *:hover +{ + text-decoration: none; + color: white; + background: #8786b7; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px +} +.openerp .oe_sidebar .oe_dropdown_menu li:hover span.oe_sidebar_attachment_action +{ + display: block; +} diff --git a/attachment_action/static/src/js/attachment_action.js b/attachment_action/static/src/js/attachment_action.js new file mode 100644 index 00000000..fb8bdfa2 --- /dev/null +++ b/attachment_action/static/src/js/attachment_action.js @@ -0,0 +1,32 @@ +//-*- coding: utf-8 -*- +//Copyright 2018 Therp BV +//License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +openerp.attachment_action = function(instance) +{ + instance.web.Sidebar.include({ + _extra_sidebar_attachment_fields: [], + on_attachments_loaded: function(attachments) + { + var self = this, _super = this._super; + return new instance.web.Model('ir.attachment') + .query(this._extra_sidebar_attachment_fields) + .filter([['id', 'in', _.pluck(attachments, 'id')]]) + .all() + .then(function(extra_data) + { + _.each(attachments, function(attachment) + { + _.extend(attachment, _.find( + extra_data, function(x) + { + return x.id == attachment.id + } + )); + }); + _super.apply(self, [attachments]); + return attachments; + }); + }, + }); +}; diff --git a/attachment_action/static/src/xml/attachment_action.xml b/attachment_action/static/src/xml/attachment_action.xml new file mode 100644 index 00000000..b66df4ea --- /dev/null +++ b/attachment_action/static/src/xml/attachment_action.xml @@ -0,0 +1,11 @@ + + + + + + + + jQuery(this).appendTo(this.siblings('.oe_sidebar_attachment_action')); + + + diff --git a/attachment_action/views/templates.xml b/attachment_action/views/templates.xml new file mode 100644 index 00000000..665d8cf7 --- /dev/null +++ b/attachment_action/views/templates.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/attachment_edit/__openerp__.py b/attachment_edit/__openerp__.py index cd5e14ae..9c8901a5 100644 --- a/attachment_edit/__openerp__.py +++ b/attachment_edit/__openerp__.py @@ -9,7 +9,7 @@ "category": "Knowledge Management", "summary": "Edit attachments after upload", "depends": [ - 'web', + 'attachment_action', ], "data": [ "views/ir_attachment.xml", diff --git a/attachment_edit/static/src/css/attachment_edit.css b/attachment_edit/static/src/css/attachment_edit.css deleted file mode 100644 index 3b25edd3..00000000 --- a/attachment_edit/static/src/css/attachment_edit.css +++ /dev/null @@ -1,22 +0,0 @@ -.openerp .oe_sidebar .oe_dropdown_menu li .oe-sidebar-attachment-edit -{ - position: absolute; - right: 32px; - top: 0px; - display: none; -} -.openerp .oe_sidebar .oe_dropdown_menu li:hover .oe-sidebar-attachment-edit -{ - display: inherit; -} -.openerp .oe_sidebar .oe_dropdown_menu li .oe-sidebar-attachment-edit:hover -{ - text-decoration: none; - color: white; - background: #8786b7; - text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - border-radius: 2px; -} - diff --git a/attachment_edit/static/src/js/attachment_edit.js b/attachment_edit/static/src/js/attachment_edit.js index 65234fd2..d25d270b 100644 --- a/attachment_edit/static/src/js/attachment_edit.js +++ b/attachment_edit/static/src/js/attachment_edit.js @@ -25,10 +25,13 @@ openerp.attachment_edit = function(instance) { on_attachments_loaded: function(attachments) { - var result = this._super.apply(this, arguments); - this.$el.find('.oe-sidebar-attachment-edit') - .click(this.on_attachment_edit); - return result; + var self = this; + return jQuery.when(this._super.apply(this, arguments)) + .then(function() + { + self.$el.find('.oe-sidebar-attachment-edit') + .click(self.on_attachment_edit); + }); }, on_attachment_edit: function(e) { diff --git a/attachment_edit/views/templates.xml b/attachment_edit/views/templates.xml index e4da3b4b..f51deabe 100644 --- a/attachment_edit/views/templates.xml +++ b/attachment_edit/views/templates.xml @@ -4,7 +4,6 @@ diff --git a/attachment_preview/__openerp__.py b/attachment_preview/__openerp__.py index 62eda094..56f7fbe4 100644 --- a/attachment_preview/__openerp__.py +++ b/attachment_preview/__openerp__.py @@ -27,7 +27,7 @@ 'summary': 'Preview attachments supported by Viewer.js', "category": "Knowledge Management", "depends": [ - 'web', + 'attachment_action', ], "data": [ "view/attachment_preview.xml", diff --git a/attachment_preview/static/src/css/attachment_preview.css b/attachment_preview/static/src/css/attachment_preview.css index 90f25f6e..887fa42f 100644 --- a/attachment_preview/static/src/css/attachment_preview.css +++ b/attachment_preview/static/src/css/attachment_preview.css @@ -1,24 +1,3 @@ -.openerp .oe_sidebar .oe_dropdown_menu li .oe-sidebar-attachment-preview -{ - position: absolute; - right: 18px; - top: 0px; - display: none; -} -.openerp .oe_sidebar .oe_dropdown_menu li:hover .oe-sidebar-attachment-preview -{ - display: inherit; -} -.openerp .oe_sidebar .oe_dropdown_menu li .oe-sidebar-attachment-preview:hover -{ - text-decoration: none; - color: white; - background: #8786b7; - text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - border-radius: 2px; -} .openerp .oe-binary-preview { cursor: pointer; diff --git a/attachment_preview/static/src/js/attachment_preview.js b/attachment_preview/static/src/js/attachment_preview.js index 2f3d7b46..d5840781 100644 --- a/attachment_preview/static/src/js/attachment_preview.js +++ b/attachment_preview/static/src/js/attachment_preview.js @@ -47,11 +47,14 @@ openerp.attachment_preview = function(instance) { on_attachments_loaded: function(attachments) { - var result = this._super.apply(this, arguments); - this.$el.find('.oe-sidebar-attachment-preview') - .click(this.on_attachment_preview); - this.update_preview_buttons(); - return result; + var self = this; + return jQuery.when(this._super.apply(this, arguments)) + .then(function() + { + self.$el.find('.oe-sidebar-attachment-preview') + .click(self.on_attachment_preview); + self.update_preview_buttons(); + }); }, on_attachment_preview: function(e) {