From 99c6701ba55576f0bc0cf2ad03d27cafa1f8a2c3 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Wed, 17 Oct 2012 12:40:08 +0530 Subject: [PATCH] [IMP] document: display name with number if more than one attachment has same number bzr revid: hmo@tinyerp.com-20121017071008-1khlntrrdi7cxgao --- addons/document/static/src/js/document.js | 17 +++++++++++++++-- addons/google_docs/static/src/js/gdocs.js | 16 ++-------------- addons/google_docs/static/src/xml/gdocs.xml | 4 ++-- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/addons/document/static/src/js/document.js b/addons/document/static/src/js/document.js index 2dde2696c81..e4bce2da76e 100644 --- a/addons/document/static/src/js/document.js +++ b/addons/document/static/src/js/document.js @@ -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); + }, }); -}; \ No newline at end of file +}; diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js index a7d9074e2c8..1cdb22aeb41 100644 --- a/addons/google_docs/static/src/js/gdocs.js +++ b/addons/google_docs/static/src/js/gdocs.js @@ -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(); }); diff --git a/addons/google_docs/static/src/xml/gdocs.xml b/addons/google_docs/static/src/xml/gdocs.xml index 85a3b3f8be0..0c8d9c3b01f 100644 --- a/addons/google_docs/static/src/xml/gdocs.xml +++ b/addons/google_docs/static/src/xml/gdocs.xml @@ -2,7 +2,7 @@ - +
  • Add Google Doc...
  • -
    \ No newline at end of file +