diff options
| author | Antonin Bourguignon <abo@openerp.com> | 2012-10-02 12:29:15 +0200 |
|---|---|---|
| committer | Antonin Bourguignon <abo@openerp.com> | 2012-10-02 12:29:15 +0200 |
| commit | 165333208000e7f8b2a61fd99c0a5b1f1d242976 (patch) | |
| tree | 150c1a7d2f30b4043b1cd565c40324b773fec3d5 /addons/google_docs/static/src | |
| parent | 2d2a44dcf2e3b29e4fef4000792a064862967769 (diff) | |
| parent | f285c0e481d12edfc2aa9aa1fd3baeb334bc39c6 (diff) | |
[MERGE] trunk
bzr revid: abo@openerp.com-20121002102915-424prxd74izb1szw
Diffstat (limited to 'addons/google_docs/static/src')
| -rw-r--r-- | addons/google_docs/static/src/js/gdocs.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js new file mode 100644 index 00000000000..bcfd24f8c0d --- /dev/null +++ b/addons/google_docs/static/src/js/gdocs.js @@ -0,0 +1,41 @@ +openerp.google_docs = function(instance, m) { +var _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; } + }); + 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) { + if (r == 'False') { + var params = { + error: response, + message: _t("The user google credentials are not set yet. Contact your administrator for help.") + } + $(openerp.web.qweb.render("DialogWarning", params)).dialog({ + title: _t("User Google credentials are not yet set."), + modal: true, + }); + } + form.reload(); + }); + }) + } + }) +} |
