mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-23 05:42:13 -06:00
[NEW] New module: attachment_attach_non_editable
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.
This commit is contained in:
19
attachment_attach_non_editable/static/src/js/sidebar.js
Normal file
19
attachment_attach_non_editable/static/src/js/sidebar.js
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
10
attachment_attach_non_editable/static/src/xml/sidebar.xml
Normal file
10
attachment_attach_non_editable/static/src/xml/sidebar.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-extend="Sidebar">
|
||||
<t t-jquery=".o_sidebar_add_attachment">
|
||||
this.attr('t-if', "section.name == 'files' and (widget.options.editable or widget.options.attachable)");
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
Reference in New Issue
Block a user