Files
odoo_source/addons/document/static/src/js/document.js
T
Géry Debongnie 4fdf74fe21 [IMP] web+addons: improvement to module system
The module system needs to know the dependencies of a given module
before executing the function.  This is why the dependencies were
defined once in an array, and then were described one more times in the
call to require.

But a trick can simplify this: the boot function can parse the string
representation of the module and extract the calls to require from it.
It is more work for the processor, but it leads to simpler module
definitions.
2015-03-18 09:23:37 +01:00

33 lines
1.0 KiB
JavaScript

odoo.define('document.document', function(require) {
"use strict";
var core = require('web.core');
var Sidebar = require('web.Sidebar');
var _t = core._t;
Sidebar.include({
init : function(){
this._super.apply(this, arguments);
if (this.getParent().view_type == "form"){
this.sections.splice(1, 0, { 'name' : 'files', 'label' : _t('Attachment(s)'), });
this.items.files = [];
}
},
on_attachments_loaded: function(attachments) {
//to display number in name if more then one attachment which has same name.
var self = this;
_.chain(attachments)
.groupBy(function(attachment) { return attachment.name; })
.each(function(attachment){
if(attachment.length > 1)
_.map(attachment, function(attachment, i){
attachment.name = _.str.sprintf(_t("%s (%s)"), attachment.name, i+1);
});
});
self._super(attachments);
},
});
});