summaryrefslogtreecommitdiff
path: root/addons/google_docs/static/src
diff options
context:
space:
mode:
authordusan <dusan@ubuntu>2012-11-16 18:47:13 +0100
committerdusan <dusan@ubuntu>2012-11-16 18:47:13 +0100
commitd1a874ebd751c74ffce81f81e4a471f3ce4c6915 (patch)
tree0f56b09179b4c78adfa1e24ea554621b88835fc1 /addons/google_docs/static/src
parent0226031b246909f4090c888f0e04845e21a1ea00 (diff)
parent8ccbab82547e45300de0ca3c83497ae7c3e4523d (diff)
[MERGE] merge with parent
bzr revid: dusan@ubuntu-20121116174713-rrcta3h4ktr0pqui
Diffstat (limited to 'addons/google_docs/static/src')
-rw-r--r--addons/google_docs/static/src/js/gdocs.js40
-rw-r--r--addons/google_docs/static/src/xml/gdocs.xml8
2 files changed, 48 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..45e1d09d42c
--- /dev/null
+++ b/addons/google_docs/static/src/js/gdocs.js
@@ -0,0 +1,40 @@
+openerp.google_docs = function(instance, m) {
+var _t = instance.web._t,
+ QWeb = instance.web.qweb;
+
+ instance.web.Sidebar.include({
+ redraw: function() {
+ var self = this;
+ this._super.apply(this, arguments);
+ self.$el.find('.oe_sidebar_add_attachment').after(QWeb.render('AddGoogleDocumentItem', {widget: self}))
+ self.$el.find('.oe_sidebar_add_google_doc').on('click', function (e) {
+ self.on_google_doc();
+ });
+ },
+ on_google_doc: function() {
+ var self = this;
+ var view = self.getParent();
+ var ids = ( view.fields_view.type != "form" )? view.groups.get_selection().ids : [ view.datarecord.id ];
+ if( !_.isEmpty(ids) ){
+ view.sidebar_context().done(function (context) {
+ var ds = new instance.web.DataSet(this, 'ir.attachment', context);
+ ds.call('google_doc_get', [view.dataset.model, ids, context]).done(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,
+ });
+ }
+ }).done(function(r){
+ window.open(r.url,"_blank");
+ view.reload();
+ });
+ });
+ }
+ }
+ });
+};
diff --git a/addons/google_docs/static/src/xml/gdocs.xml b/addons/google_docs/static/src/xml/gdocs.xml
new file mode 100644
index 00000000000..0c8d9c3b01f
--- /dev/null
+++ b/addons/google_docs/static/src/xml/gdocs.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vim:fdl=1:
+-->
+<templates id="template" xml:space="preserve">
+<t t-name="AddGoogleDocumentItem">
+ <li class="oe_sidebar_add_google_doc"><span><b>Add Google Doc...</b></span></li>
+</t>
+</templates>