diff --git a/attachment_preview/static/src/js/attachment_preview.js b/attachment_preview/static/src/js/attachment_preview.js index 3f1f6604..b2c6b339 100644 --- a/attachment_preview/static/src/js/attachment_preview.js +++ b/attachment_preview/static/src/js/attachment_preview.js @@ -1,7 +1,7 @@ -///* Copyright 2014 Therp BV () -// * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ +/* Copyright 2014 Therp BV () + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ -odoo.define('attachment_preview', function(require) { +odoo.define('attachment_preview', function (require) { 'use strict'; var core = require('web.core'); @@ -14,16 +14,15 @@ odoo.define('attachment_preview', function(require) { var Widget = require('web.Widget'); var AttachmentPreviewMixin = { - canPreview: function(extension) { + canPreview: function (extension) { return $.inArray( extension, - [ - 'odt', 'odp', 'ods', 'fodt', 'pdf', 'ott', 'fodp', 'otp', - 'fods', 'ots' + ['odt', 'odp', 'ods', 'fodt', 'pdf', 'ott', 'fodp', 'otp', + 'fods', 'ots', ]) > -1; }, - getUrl: function(attachment_id, attachment_url, attachment_extension, attachment_title) { + getUrl: function (attachment_id, attachment_url, attachment_extension, attachment_title) { var url = (window.location.origin || '') + '/attachment_preview/static/lib/ViewerJS/index.html' + '?type=' + encodeURIComponent(attachment_extension) + @@ -33,7 +32,7 @@ odoo.define('attachment_preview', function(require) { return url; }, - showPreview: function(attachment_id, attachment_url, attachment_extension, attachment_title, split_screen) { + showPreview: function (attachment_id, attachment_url, attachment_extension, attachment_title, split_screen) { var url = this.getUrl(attachment_id, attachment_url, attachment_extension, attachment_title); if (split_screen) { this.trigger_up('onAttachmentPreview', {url: url}); @@ -46,51 +45,51 @@ odoo.define('attachment_preview', function(require) { Sidebar.include(AttachmentPreviewMixin); Sidebar.include({ events: _.extend({}, Sidebar.prototype.events, { - 'click .o_sidebar_preview_attachment': '_onPreviewAttachment' + 'click .o_sidebar_preview_attachment': '_onPreviewAttachment', }), previewableAttachments: null, _redraw: function () { this._super.apply(this, arguments); - this.getPreviewableAttachments().done(function(atts) { + this.getPreviewableAttachments().done(function (atts) { this.previewableAttachments = atts; this.updatePreviewButtons(atts); this.trigger_up('setPreviewableAttachments', {attachments: atts}); }.bind(this)); }, - _onPreviewAttachment: function(event) { + _onPreviewAttachment: function (event) { event.preventDefault(); var self = this, $target = $(event.currentTarget), - split_screen = $target.attr('data-target') != 'new', + split_screen = $target.attr('data-target') !== 'new', attachment_id = parseInt($target.attr('data-id'), 10), attachment_url = $target.attr('data-url'), attachment_extension = $target.attr('data-extension'), attachment_title = $target.attr('data-original-title'); - if(attachment_extension) { + if (attachment_extension) { this.showPreview(attachment_id, attachment_url, attachment_extension, attachment_title, split_screen); } else { this._rpc({ model: 'ir.attachment', method: 'get_attachment_extension', - args: [attachment_id] - }).then(function(extension) { + args: [attachment_id], + }).then(function (extension) { self.showPreview(attachment_id, attachment_url, extension, null, split_screen); }); } }, - getPreviewableAttachments: function() { + getPreviewableAttachments: function () { var self = this; var deferred = $.Deferred(); var $items = this.$el.find('.o_sidebar_preview_attachment'); - var attachments = _.object($items.map(function() { + var attachments = _.object($items.map(function () { return parseInt($(this).attr('data-id'), 10); - }), $items.map(function() { + }), $items.map(function () { return { url: $(this).attr('data-url'), extension: $(this).attr('data-extension'), @@ -102,14 +101,14 @@ odoo.define('attachment_preview', function(require) { model: 'ir.attachment', method: 'get_attachment_extension', args: [ - _.map(_.keys(attachments), function(id) { + _.map(_.keys(attachments), function (id) { return parseInt(id, 10); - }) - ] - }).then(function(extensions) { - var reviewableAttachments = _.map(_.keys(_.pick(extensions, function(extension, id) { + }), + ], + }).then(function (extensions) { + var reviewableAttachments = _.map(_.keys(_.pick(extensions, function (extension, id) { return self.canPreview(extension); - })), function(id) { + })), function (id) { return { id: id, url: attachments[id]['url'], @@ -120,18 +119,18 @@ odoo.define('attachment_preview', function(require) { attachments[id]['url'], extensions[id], id + ' - ' + attachments[id]['title'] - ) - } + ), + }; }); deferred.resolve(reviewableAttachments); - }, function() { + }, function () { deferred.reject(); }); return deferred.promise(); }, - updatePreviewButtons: function(previewableAttachments) { - this.$el.find('.o_sidebar_preview_attachment').each(function() { + updatePreviewButtons: function (previewableAttachments) { + this.$el.find('.o_sidebar_preview_attachment').each(function () { var $this = $(this); var id = $this.attr('data-id'); var att = _.findWhere(previewableAttachments, {id: id}); @@ -147,20 +146,20 @@ odoo.define('attachment_preview', function(require) { basic_fields.FieldBinaryFile.include(AttachmentPreviewMixin); basic_fields.FieldBinaryFile.include({ events: _.extend({}, basic_fields.FieldBinaryFile.prototype.events, { - 'click .fa-search': '_onPreview' + 'click .fa-search': '_onPreview', }), _renderReadonly: function () { var self = this; this._super.apply(this, arguments); - this._getBinaryExtension().done(function(extension) { - if(self.canPreview(extension)) { + this._getBinaryExtension().done(function (extension) { + if (self.canPreview(extension)) { self._renderPreviewButton(extension); } }); }, - _renderPreviewButton: function(extension) { + _renderPreviewButton: function (extension) { this.$previewBtn = $(""); this.$previewBtn.addClass('fa fa-search'); this.$previewBtn.attr('title', _.str.sprintf(_t('Preview %s'), this.field.string)); @@ -176,12 +175,12 @@ odoo.define('attachment_preview', function(require) { this.model, this.recordData.id, this.name, - this.attrs.filename - ] + this.attrs.filename, + ], }); }, - _onPreview: function(event) { + _onPreview: function (event) { this.showPreview( null, _.str.sprintf( @@ -194,7 +193,7 @@ odoo.define('attachment_preview', function(require) { _.str.sprintf(_t('Preview %s'), this.field.string), false ); - } + }, }); var AttachmentPreviewWidget = Widget.extend({ @@ -237,7 +236,7 @@ odoo.define('attachment_preview', function(require) { window.open(this.attachments[this.activeIndex].previewUrl); }, - next: function() { + next: function () { var index = this.activeIndex + 1; if (index >= this.attachments.length) { index = 0; @@ -247,7 +246,7 @@ odoo.define('attachment_preview', function(require) { this.loadPreview(); }, - previous: function() { + previous: function () { var index = this.activeIndex - 1; if (index < 0) { index = this.attachments.length - 1; @@ -267,13 +266,13 @@ odoo.define('attachment_preview', function(require) { this.trigger('hidden'); }, - updatePaginator: function() { + updatePaginator: function () { var value = _.str.sprintf('%s / %s', this.activeIndex + 1, this.attachments.length); this.$current.html(value); }, - loadPreview: function() { - if (this.attachments.length == 0) { + loadPreview: function () { + if (this.attachments.length === 0) { this.$iframe.attr('src', 'about:blank'); return; } @@ -282,18 +281,18 @@ odoo.define('attachment_preview', function(require) { this.$iframe.attr('src', att.previewUrl); }, - setAttachments: function(attachments) { + setAttachments: function (attachments) { this.attachments = attachments; this.activeIndex = 0; this.updatePaginator(); this.loadPreview(); - } + }, }); FormRenderer.include({ attachmentPreviewWidget: null, - init: function() { + init: function () { var res = this._super.apply(this, arguments); this.attachmentPreviewWidget = new AttachmentPreviewWidget(this); this.attachmentPreviewWidget.on('hidden', this, this._attachmentPreviewWidgetHidden); @@ -305,7 +304,7 @@ odoo.define('attachment_preview', function(require) { this.attachmentPreviewWidget.insertAfter(this.$el); }, - _attachmentPreviewWidgetHidden: function() { + _attachmentPreviewWidgetHidden: function () { this.$el.removeClass('attachment_preview'); }, @@ -320,29 +319,29 @@ odoo.define('attachment_preview', function(require) { on_detach_callback: function () { this.attachmentPreviewWidget.hide(); return this._super.apply(this, arguments); - } + }, }); FormController.include({ custom_events: _.extend({}, FormController.prototype.custom_events, { onAttachmentPreview: '_onAttachmentPreview', - setPreviewableAttachments: '_setPreviewableAttachments' + setPreviewableAttachments: '_setPreviewableAttachments', }), _onAttachmentPreview: function (event) { this.renderer.showAttachmentPreviewWidget(); }, - _setPreviewableAttachments: function(event) { + _setPreviewableAttachments: function (event) { this.renderer.attachmentPreviewWidget.setAttachments( event.data.attachments ); - } + }, }); return { AttachmentPreviewMixin: AttachmentPreviewMixin, - AttachmentPreviewWidget: AttachmentPreviewWidget + AttachmentPreviewWidget: AttachmentPreviewWidget, }; }); diff --git a/attachment_preview/static/src/js/viewerjs_tweaks.js b/attachment_preview/static/src/js/viewerjs_tweaks.js index 42f9d836..cd8a0cdc 100644 --- a/attachment_preview/static/src/js/viewerjs_tweaks.js +++ b/attachment_preview/static/src/js/viewerjs_tweaks.js @@ -3,9 +3,9 @@ // This file contains tweaks for viewerjs itself and is not meant to be run in // OpenERP's context -(function(original_Viewer) { - window.Viewer = function(plugin, parameters) { - if(!plugin) { +(function (original_Viewer) { + window.Viewer = function (plugin, parameters) { + if (!plugin) { // eslint-disable-next-line no-alert alert('Unsupported file type'); } diff --git a/document_page_approval/views/document_page_approval.xml b/document_page_approval/views/document_page_approval.xml index 5f7759c6..610ce4de 100644 --- a/document_page_approval/views/document_page_approval.xml +++ b/document_page_approval/views/document_page_approval.xml @@ -39,7 +39,7 @@ - + {'readonly': [('state', 'not in', ['draft'])]} {'readonly': [('state', 'not in', ['draft'])]} {'readonly': [('state', 'not in', ['draft'])]} diff --git a/document_page_project/__manifest__.py b/document_page_project/__manifest__.py index a363a5e1..42933466 100644 --- a/document_page_project/__manifest__.py +++ b/document_page_project/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'Project Wiki', - 'description': 'This module links document pages to projects', + 'summary': 'This module links document pages to projects', 'version': '11.0.1.0.0', "development_status": "Beta", 'category': 'Project', diff --git a/document_url/security/ir.model.access.csv b/document_url/security/ir.model.access.csv index 8c8e2e25..6f32fcb0 100644 --- a/document_url/security/ir.model.access.csv +++ b/document_url/security/ir.model.access.csv @@ -1,2 +1,2 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_ir_attachment_add_url,access_ir_attachment_add_url,model_ir_attachment_add_url,,1,1,1,1 \ No newline at end of file +access_ir_attachment_add_url,access_ir_attachment_add_url,model_ir_attachment_add_url,,1,1,1,1 diff --git a/document_url/static/src/js/url.js b/document_url/static/src/js/url.js index 988d3e66..08062fd1 100644 --- a/document_url/static/src/js/url.js +++ b/document_url/static/src/js/url.js @@ -21,7 +21,7 @@ odoo.define('document_url', function (require) { self.$el.find("a[href]").attr('target', '_blank'); self.$el .find('.oe_sidebar_add_attachment, .o_sidebar_add_attachment') - .after(QWeb.render('AddUrlDocumentItem', {widget: self})) + .after(QWeb.render('AddUrlDocumentItem', {widget: self})); self.$el.find('.o_sidebar_add_url').on('click', function (e) { self.on_url_doc(); }); @@ -29,7 +29,7 @@ odoo.define('document_url', function (require) { on_url_doc: function (event) { var self = this; - var env = self.env + var env = self.env; var view = self.getParent(); var ids = self.env.activeIds; if (!_.isEmpty(ids)) { @@ -41,7 +41,7 @@ odoo.define('document_url', function (require) { if (env.domain) { activeIdsContext.active_domain = env.domain; } - var context = new Context(env.context, activeIdsContext) + var context = new Context(env.context, activeIdsContext); context = pyeval.eval('context', context); self._rpc({ route: "/web/action/load", diff --git a/knowledge/__manifest__.py b/knowledge/__manifest__.py index 45a9d663..41bc44a1 100644 --- a/knowledge/__manifest__.py +++ b/knowledge/__manifest__.py @@ -2,10 +2,11 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Knowledge Management System", - "version": "11.0.2.0.0", + "version": "11.0.3.0.0", "author": "OpenERP SA," "MONK Software, " "Tecnativa, " + "Eficent, " "Odoo Community Association (OCA)", "category": "Knowledge", "license": "AGPL-3", diff --git a/knowledge/models/res_config.py b/knowledge/models/res_config.py index 369bb130..ba6bfd4a 100644 --- a/knowledge/models/res_config.py +++ b/knowledge/models/res_config.py @@ -9,11 +9,17 @@ class KnowledgeConfigSettings(models.TransientModel): _inherit = 'res.config.settings' module_document = fields.Boolean( - 'Manage documents', + 'Attachments List and Document Indexation', help='Document indexation, full text search of attachements.\n' '- This installs the module document.' ) + group_ir_attachment_user = fields.Boolean( + string='Central access to Documents', + help="When you set this field all users will be able to manage " + "attachments centrally, from the Knowledge/Documents menu.", + implied_group='knowledge.group_ir_attachment_user') + module_document_page = fields.Boolean( 'Manage document pages (Wiki)', help='Provide document page and category as a wiki.\n' diff --git a/knowledge/readme/CONFIGURE.rst b/knowledge/readme/CONFIGURE.rst new file mode 100644 index 00000000..ff972422 --- /dev/null +++ b/knowledge/readme/CONFIGURE.rst @@ -0,0 +1,20 @@ +To set up this module, you need to go to: + +* Knowledge / Configuration / Settings + +From this menu you'll have a central access to install the apps that belong +to Knowledge. + +* Check *Attachments List and Document Indexation* if you want to install the + module that allows users to attach documents to any model. +* Check *Manage attachments centrally* if you want all users to be able to + access to the all attachments to which they have read permissions, from the + menu *Knowledge / Documents* + +If you want to grant Central Access to Documents only to some users: + +#. Go to *Settings/Activate the developer mode*. Only a user with + *Administration / Settings* permissions can do that. + +#. Go to *Settings / Users & Companies / Users* and set the checkbox + *Central access to Documents* to the selected users. diff --git a/knowledge/readme/CONTRIBUTORS.rst b/knowledge/readme/CONTRIBUTORS.rst index 8f4f234c..b5d4b9fa 100644 --- a/knowledge/readme/CONTRIBUTORS.rst +++ b/knowledge/readme/CONTRIBUTORS.rst @@ -6,3 +6,4 @@ * Fayez Qandeel * Vicent Cubells * Iván Todorovich +* Jordi Ballester diff --git a/knowledge/readme/ROADMAP.rst b/knowledge/readme/ROADMAP.rst index ce23930f..e69de29b 100644 --- a/knowledge/readme/ROADMAP.rst +++ b/knowledge/readme/ROADMAP.rst @@ -1,2 +0,0 @@ -* Migrate related modules to v11 and add options in the settings as soon as - they are installable. diff --git a/knowledge/readme/USAGE.rst b/knowledge/readme/USAGE.rst index fa66f7bc..328eb25e 100644 --- a/knowledge/readme/USAGE.rst +++ b/knowledge/readme/USAGE.rst @@ -1,3 +1,5 @@ -To use this module, you need to: +This module adds a new top level menu *Knowledge* -* Go to Knowledge / Configuration / Settings +Users with permission *Central access to Documents* can access in +*Knowledge/Documents* to all the documents attached to records of any model +for which they have read permission. diff --git a/knowledge/security/knowledge_security.xml b/knowledge/security/knowledge_security.xml index d377b590..a2470037 100644 --- a/knowledge/security/knowledge_security.xml +++ b/knowledge/security/knowledge_security.xml @@ -7,4 +7,10 @@ + + Central access to Documents + + + + diff --git a/knowledge/views/knowledge.xml b/knowledge/views/knowledge.xml index 82772fd9..86020124 100644 --- a/knowledge/views/knowledge.xml +++ b/knowledge/views/knowledge.xml @@ -37,9 +37,9 @@ + sequence="150"/> +
+
+ +
+
+
+
@@ -75,7 +83,7 @@ name="Configuration" parent="menu_document_root" groups="base.group_system" - sequence="50"/> + sequence="200"/>