diff options
| author | Vijaykumar Baladaniya <vba@tinyerp.com> | 2012-10-15 11:44:32 +0530 |
|---|---|---|
| committer | Vijaykumar Baladaniya <vba@tinyerp.com> | 2012-10-15 11:44:32 +0530 |
| commit | eb0b0650c435feef106c1e22de65e217111ee1b2 (patch) | |
| tree | 60dfea6ac9f8709f7fea23e51ff34b3022d588fd /addons/google_docs/static/src/js/gdocs.js | |
| parent | 2c6281b4fb1c1512c4bdeb5e70c7e17fd73c5a67 (diff) | |
| parent | 81b2e5c8ae46d795bf6e0cb7fc620d60f5c5b291 (diff) | |
[MERGE]Merge with trunk-google-doc-imp-rga.
bzr revid: vba@tinyerp.com-20121015061432-ugrpvdx98k2n7q4e
Diffstat (limited to 'addons/google_docs/static/src/js/gdocs.js')
| -rw-r--r-- | addons/google_docs/static/src/js/gdocs.js | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js index bcfd24f8c0d..c2c0ded407b 100644 --- a/addons/google_docs/static/src/js/gdocs.js +++ b/addons/google_docs/static/src/js/gdocs.js @@ -1,28 +1,22 @@ openerp.google_docs = function(instance, m) { -var _t = instance.web._t; +var QWeb = instance.web.qweb, + _t = instance.web._t; instance.web.Sidebar = instance.web.Sidebar.extend({ - on_attachments_loaded: function(attachments) { - var self = this; - self._super(attachments); - // if attachment contains a google doc url do nothing - // else display a button to create a google doc - var flag = false; - _.each(attachments, function(i) { - if (i.url && i.url.match('/docs.google.com/')) { flag = true; } + 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_google_doc').on('click', function (e) { + self.on_google_doc(); }); - if (! flag) { - this.add_items('files', [ - { label: _t('Add Google Doc...'), callback: self.on_google_doc }, - ]); - } }, on_google_doc: function() { var self = this; var form = self.getParent(); form.sidebar_context().then(function (context) { var ds = new instance.web.DataSet(this, 'ir.attachment', context); - ds.call('google_doc_get', [form.dataset.model, [form.datarecord.id], context], function(r) { + def = ds.call('google_doc_get', [form.dataset.model, [form.datarecord.id], context], function(r) { if (r == 'False') { var params = { error: response, @@ -33,8 +27,10 @@ var _t = instance.web._t; modal: true, }); } - form.reload(); - }); + + }).done(function(){ + form.reload(); + }); }) } }) |
