summaryrefslogtreecommitdiff
path: root/addons/google_docs/static/src
diff options
context:
space:
mode:
authorPurnendu Singh (OpenERP) <psi@tinyerp.com>2012-06-06 11:06:52 +0530
committerPurnendu Singh (OpenERP) <psi@tinyerp.com>2012-06-06 11:06:52 +0530
commit9a8d73eda55676ba243acdaf454d06a78e2b5054 (patch)
treed8182ae5e778b32bb9ee638da8d523f3d7ffc50f /addons/google_docs/static/src
parent742124c840b0b456c7eb48ebec753fb1303d883c (diff)
parent3ba4a8bdbb3d23e11e1c465afc8cb5710d30a331 (diff)
[MERGE] merge with main addons
bzr revid: psi@tinyerp.com-20120606053652-i211xuzmdo1qkgqr
Diffstat (limited to 'addons/google_docs/static/src')
-rw-r--r--addons/google_docs/static/src/js/gdocs.js41
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();
+ });
+ })
+ }
+ })
+}