[ADD] allow to override attachment sorting

This commit is contained in:
Holger Brunn 2015-04-20 09:55:15 +02:00
parent 34fd9b66f5
commit f09f877f3e

View File

@ -52,7 +52,8 @@ openerp.document_choose_directory = function(instance)
}, },
on_attachments_loaded: function(attachments) on_attachments_loaded: function(attachments)
{ {
var attachments_per_directory = []; var self = this,
attachments_per_directory = [];
_.chain(attachments) _.chain(attachments)
.groupBy( .groupBy(
function(a) { return a.parent_id[0] }) function(a) { return a.parent_id[0] })
@ -64,7 +65,7 @@ openerp.document_choose_directory = function(instance)
instance.web._t('No directory'), instance.web._t('No directory'),
classname: 'oe_attachment_directory', classname: 'oe_attachment_directory',
}); });
_(group).each(function(a) self.sort_attachments(group).each(function(a)
{ {
attachments_per_directory.push(a); attachments_per_directory.push(a);
}); });
@ -80,5 +81,9 @@ openerp.document_choose_directory = function(instance)
return i.classname == 'oe_attachment_directory'; return i.classname == 'oe_attachment_directory';
}); });
}, },
sort_attachments: function(attachments)
{
return _.chain(attachments).sortBy('name');
},
}); });
} }