diff options
| author | Amit (OpenERP) <amp@tinyerp.com> | 2012-09-03 15:02:01 +0530 |
|---|---|---|
| committer | Amit (OpenERP) <amp@tinyerp.com> | 2012-09-03 15:02:01 +0530 |
| commit | 47cb33a81b1e8aca9d43fd4d0cfa2c100eed728b (patch) | |
| tree | baf4cf2db3a285a8041a3469419f9a669b4cdb2e /addons/google_docs/static/src/js/gdocs.js | |
| parent | 041294a4d1d692fd3db4c819e17a4329df54d34f (diff) | |
| parent | e3f1c26e6afcf7c3df9bd98166614778e27645ea (diff) | |
[Merge] Merge with main addons
bzr revid: amp@tinyerp.com-20120903093201-eq3x6k3zthdh9cve
Diffstat (limited to 'addons/google_docs/static/src/js/gdocs.js')
| -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..694f5736c72 --- /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('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(); + }); + }) + } + }) +} |
