summaryrefslogtreecommitdiff
path: root/addons/google_docs/static/src
diff options
context:
space:
mode:
authorTejas Tank <tta@openerp.com>2012-07-17 15:48:45 +0530
committerTejas Tank <tta@openerp.com>2012-07-17 15:48:45 +0530
commit45c50d3a31cc9627e61384bd0c1c80f22c5e740e (patch)
tree98a72dfe089805dd23e59997b62fca546c4c2255 /addons/google_docs/static/src
parent51b1ae8bfc710388638ca4b81c6b834fbc105bcd (diff)
parent6dac47419fa0b65f6be078e74e2664fcb95a2bc4 (diff)
merged lasted + resolve conflicts + etherpad with project.task
bzr revid: tta@openerp.com-20120717101845-52upauotn1sjfqio
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();
+ });
+ })
+ }
+ })
+}