diff --git a/attachment_attach_non_editable/README.rst b/attachment_attach_non_editable/README.rst new file mode 100644 index 00000000..564ed991 --- /dev/null +++ b/attachment_attach_non_editable/README.rst @@ -0,0 +1,56 @@ +.. 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 + +=============================== +Force enable attachments upload +=============================== + +In odoo, by default, you can't add attachments to a record if the form view +is set as not editable (``edit='false'`` in the form tag) + +This module adds a new form view attribute, ``attach=``, which lets you +enable attachment uploads even in non-editable forms. + +Usage +===== + +Add the ``attach=true`` attribute to the form view tag which of uneditable views +(normal editable views already allow attaching a document and there is no need +for this attribute). + + +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 `here `_. + + +Credits +======= + +Contributors +------------ + +* Leonardo Donelli @ MONK Software (leonardo.donelli@monksoftware.it) + +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 http://odoo-community.org. diff --git a/attachment_attach_non_editable/__init__.py b/attachment_attach_non_editable/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/attachment_attach_non_editable/__manifest__.py b/attachment_attach_non_editable/__manifest__.py new file mode 100644 index 00000000..80e1e977 --- /dev/null +++ b/attachment_attach_non_editable/__manifest__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 MONK Software +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Force enable attachments", + "version": "10.0.1.0.0", + "author": "MONK Software, Odoo Community Association (OCA)", + "category": "Knowledge", + "license": "AGPL-3", + "website": "https://odoo-community.org/", + "depends": ["document"], + "data": [ + 'templates/web.xml', + ], + "qweb": [ + 'static/src/xml/sidebar.xml', + ], + "installable": True, + "auto_install": False, +} diff --git a/attachment_attach_non_editable/static/src/js/sidebar.js b/attachment_attach_non_editable/static/src/js/sidebar.js new file mode 100644 index 00000000..4985d29c --- /dev/null +++ b/attachment_attach_non_editable/static/src/js/sidebar.js @@ -0,0 +1,19 @@ +odoo.define('attachment_attach_non_editable.sidebar', function(require) { + "use strict"; + + var core = require('web.core'); + var Sidebar = require('web.Sidebar'); + + + Sidebar.include({ + + init: function(parent, options) { + this._super.apply(this, arguments); + if (parent.is_action_enabled('attach')) { + this.options.attachable = true; + } + } + + }); + +}); diff --git a/attachment_attach_non_editable/static/src/xml/sidebar.xml b/attachment_attach_non_editable/static/src/xml/sidebar.xml new file mode 100644 index 00000000..2b314f90 --- /dev/null +++ b/attachment_attach_non_editable/static/src/xml/sidebar.xml @@ -0,0 +1,10 @@ + + + + + + this.attr('t-if', "section.name == 'files' and (widget.options.editable or widget.options.attachable)"); + + + + diff --git a/attachment_attach_non_editable/templates/web.xml b/attachment_attach_non_editable/templates/web.xml new file mode 100644 index 00000000..0a0f5769 --- /dev/null +++ b/attachment_attach_non_editable/templates/web.xml @@ -0,0 +1,10 @@ + + + + + +