diff options
| author | Frédéric van der Essen <fva@openerp.com> | 2012-07-10 16:24:47 +0200 |
|---|---|---|
| committer | Frédéric van der Essen <fva@openerp.com> | 2012-07-10 16:24:47 +0200 |
| commit | f8d32d3304341e17d10a63cd8fe2f36819104943 (patch) | |
| tree | 01de11faa1a8f58f21903fdd57e6858f43d7001f /addons/google_docs/static/src/js/gdocs.js | |
| parent | dd2384325b0460e9bc4779938aed5f21c70ef4df (diff) | |
| parent | cc98560cfdab6308ed5db87b266cdbb6b9ff4f74 (diff) | |
[MERGE] point_of_sale
bzr revid: fva@openerp.com-20120710142447-s0z5ca89bofh0n2c
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..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(); + }); + }) + } + }) +} |
