diff --git a/addons/google_docs/__openerp__.py b/addons/google_docs/__openerp__.py index b1cfd1490d5..1df94f34221 100644 --- a/addons/google_docs/__openerp__.py +++ b/addons/google_docs/__openerp__.py @@ -29,9 +29,6 @@ 'auto_install': False, 'web': True, 'js': ['static/src/js/gdocs.js'], - 'qweb' : [ - "static/src/xml/gdocs.xml", - ], 'update_xml': [ 'res_config_user_view.xml' ], 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(); }); - }, - }); + } + } }; - diff --git a/addons/google_docs/static/src/xml/gdocs.xml b/addons/google_docs/static/src/xml/gdocs.xml deleted file mode 100644 index 2de7efcbd43..00000000000 --- a/addons/google_docs/static/src/xml/gdocs.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - -