diff options
| author | Divyesh Makwana (Open ERP) <mdi@tinyerp.com> | 2012-05-28 11:52:05 +0530 |
|---|---|---|
| committer | Divyesh Makwana (Open ERP) <mdi@tinyerp.com> | 2012-05-28 11:52:05 +0530 |
| commit | d18cb96c971bf3f87b041ce79280d377effa0f6f (patch) | |
| tree | 0c5e43c424f98d57429dce3ceca3cfff857e7276 /addons/google_docs/static/src/js | |
| parent | 3f148674c2e57ae71e66679360b968da0e1f6692 (diff) | |
| parent | 099c4e574a5f11720c162216efb88cec48380be1 (diff) | |
[Merge] Merge with main addons.
bzr revid: mdi@tinyerp.com-20120528062205-ukjcxs41f917dsk2
Diffstat (limited to 'addons/google_docs/static/src/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..8f41a9d7b21 --- /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) { + 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(); + }); + }) + } + }) +} |
