diff options
| author | Denis Ledoux dle@openerp.com <> | 2012-11-08 10:28:38 +0100 |
|---|---|---|
| committer | Denis Ledoux dle@openerp.com <> | 2012-11-08 10:28:38 +0100 |
| commit | 981168dfc6d628c72d8469022c0b51e0f5ec00df (patch) | |
| tree | e7497e1366dcd0b7759ed6eae9d2fa8b50ff46c5 /addons/google_docs/static/src/js | |
| parent | 9e56b3b6a8a761e02099146b338225d29dbc8c8a (diff) | |
| parent | 29fffbc97d8970513114b7b76763f002aa73e395 (diff) | |
[ADD][MERGE]Add functionnalities, merge with trunk
bzr revid: dle@openerp.com-20121108092838-fe89ohg9za3ln6y1
Diffstat (limited to 'addons/google_docs/static/src/js')
| -rw-r--r-- | addons/google_docs/static/src/js/gdocs.js | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js index 2aafdd3de4b..0cc93b2510c 100644 --- a/addons/google_docs/static/src/js/gdocs.js +++ b/addons/google_docs/static/src/js/gdocs.js @@ -1,41 +1,40 @@ openerp.google_docs = function(instance, m) { -var _t = instance.web._t; +var _t = instance.web._t, + QWeb = instance.web.qweb; - instance.web.Sidebar = instance.web.Sidebar.extend({ - on_attachments_loaded: function(attachments) { + instance.web.Sidebar.include({ + redraw: function() { var 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; } + 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(); }); - if (! flag) { - this.add_items('files', [ - { label: _t('Add 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]).then(function(r) { - if (r == 'False') { - var params = { - error: response, - message: _t("The user google credentials are not set yet. Contact your administrator for help.") + 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().then(function (context) { + var ds = new instance.web.DataSet(this, 'ir.attachment', context); + ds.call('google_doc_get', [view.dataset.model, ids, context]).then(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, + }); } - $(openerp.web.qweb.render("DialogWarning", params)).dialog({ - title: _t("User Google credentials are not yet set."), - modal: true, - }); - } - form.reload(); + }).done(function(r){ + window.open(r.url,"_blank"); + view.reload(); + }); }); - }); + } } }); }; |
