diff options
Diffstat (limited to 'addons/google_docs/static/src/js/gdocs.js')
| -rw-r--r-- | addons/google_docs/static/src/js/gdocs.js | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js index a8e941f01f6..6fe830d383c 100644 --- a/addons/google_docs/static/src/js/gdocs.js +++ b/addons/google_docs/static/src/js/gdocs.js @@ -1,29 +1,19 @@ -openerp.google_docs = function(instance, session) { - - - instance.web.form.SidebarAttachments = instance.web.form.SidebarAttachments.extend({ - init: function() { - this._super.apply(this, arguments); - this.$element.delegate('.oe_google_docs_text_button', 'click', this.on_add_text_gdoc); - }, - - - on_attachments_loaded: function(attachments) { - this._super(attachments); - var config = new instance.web.DataSet(this, 'google.docs.config', this.view.dataset.get_context()); - config.call('get_config', [[this.view.datarecord.id],this.view.dataset.model,this.view.dataset.get_context()], function(r) { - if (r == false){ - $('.oe_google_docs_text_button',this.$element).hide(); - } - }); - }, - - on_add_text_gdoc: function() { - var self = this; - var $gdocbtn = this.$element.find('.oe_google_docs_text_button'); - $gdocbtn.attr('disabled', 'true').find('img, span').toggle(); - var ds = new instance.web.DataSet(this, 'google.docs', this.view.dataset.get_context()); - ds.call('doc_get', [this.view.dataset.model, [this.view.datarecord.id], 'text'], function(r) { +openerp.google_docs = function(instance, m) { + instance.web.Sidebar = instance.web.Sidebar.extend({ + on_attachments_loaded: function(attachments) { + self._super(attachements); + // if attachment contains a google doc url do nothing + // else + this.sidebar.add_items('other', [ + { label: _t('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, 'google.docs', context); + ds.call('doc_get', [form.view.dataset.model, [form.view.datarecord.id], 'text'], function(r) { if (r == 'False') { var params = { error: response, @@ -34,9 +24,8 @@ openerp.google_docs = function(instance, session) { modal: true, }); } - self.do_update(); + view.reload(); }); - }, - }); + } + } }; - |
