Skip to content

Commit

Permalink
[IMP] document: display name with number if more than one attachment …
Browse files Browse the repository at this point in the history
…has same number

bzr revid: hmo@tinyerp.com-20121017071008-1khlntrrdi7cxgao
  • Loading branch information
hmo-odoo committed Oct 17, 2012
1 parent fee84c9 commit 99c6701
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
17 changes: 15 additions & 2 deletions addons/document/static/src/js/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ openerp.document = function (instance) {
this._super.apply(this, arguments);
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);
},
});
};
};
16 changes: 2 additions & 14 deletions addons/google_docs/static/src/js/gdocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,11 @@ openerp.google_docs = function(instance, m) {
var _t = instance.web._t,
QWeb = instance.web.qweb;

instance.web.Sidebar = instance.web.Sidebar.extend({
on_attachments_loaded: function(attachments) {
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);
},
instance.web.Sidebar.include({
redraw: function() {
var self = this;
this._super.apply(this, arguments);
self.$el.find('.oe_sidebar_add_attachment').after(QWeb.render('Google_doc', {widget: self}))
self.$el.find('.oe_sidebar_add_attachment').after(QWeb.render('AddGoogleDocumentItem', {widget: self}))
self.$el.find('.oe_sidebar_add_google_doc').on('click', function (e) {
self.on_google_doc();
});
Expand Down
4 changes: 2 additions & 2 deletions addons/google_docs/static/src/xml/gdocs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- vim:fdl=1:
-->
<templates id="template" xml:space="preserve">
<t t-name="Google_doc">
<t t-name="AddGoogleDocumentItem">
<li class="oe_sidebar_add_google_doc"><span><b>Add Google Doc...</b></span></li>
</t>
</templates>
</templates>

0 comments on commit 99c6701

Please sign in to comment.