diff options
| author | MVA <mva@openerp.com> | 2012-04-02 15:18:17 +0200 |
|---|---|---|
| committer | MVA <mva@openerp.com> | 2012-04-02 15:18:17 +0200 |
| commit | fb989dbfb7161b9f79ce5bf2024a5f13423b1b6f (patch) | |
| tree | 8a57faca5ae8f35391ef560092e741df382e4e95 /addons/google_docs/static/src | |
| parent | ac63b945f618e21bfe62e751e4afe958e2d8c04c (diff) | |
[IMP] change the way to name the attachement and change when you already have a google document the button will be hide
bzr revid: mva@openerp.com-20120402131817-oxv227m8i11pfsjx
Diffstat (limited to 'addons/google_docs/static/src')
| -rw-r--r-- | addons/google_docs/static/src/js/gdocs.js | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js index 9dc4f5c88d3..425de5045d8 100644 --- a/addons/google_docs/static/src/js/gdocs.js +++ b/addons/google_docs/static/src/js/gdocs.js @@ -5,31 +5,35 @@ openerp.google_docs = function(instance, session) { init: function() { this._super.apply(this, arguments); this.$element.delegate('.oe_google_docs_text_button', 'click', this.on_add_text_gdoc); - var self = this; - var config = new instance.web.DataSet(this, 'google.docs.config', this.view.dataset.get_context()); - config.call('get_config', [this.view.dataset.ids[this.view.dataset.index]], function(r) { - // if the configuration isn't set, the buttons should be hidden. - if (r==false) { - $('.oe_google_docs_text_button',this.$element).hide(); - return; - } - - var attachment = new instance.web.DataSet(this, 'ir.attachment', self.view.dataset.get_context()); - attachment.call('copy_gdoc', [self.view.dataset.model, [self.view.datarecord.id]], function(res) { - }); - }); - }, - start: function() { - this._super(); - console.log($('.oe_google_docs_text_button',this.$element)) - $('.oe_google_docs_text_button',this.$element) }, + + + 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) { + if (r == 'False') { + var params = { + error: response, + message: "The user google credentials are not set yet. Contact your administrator for help." + } + $(openerp.web.qweb.render("DialogWarning", params)).dialog({ + title: "User Google credentials are not yet set.", + modal: true, + }); + } self.do_update(); }); }, |
