diff options
| author | Dharti Ratani (Open ERP) <dhr@tinyerp.com> | 2013-03-08 19:00:39 +0530 |
|---|---|---|
| committer | Dharti Ratani (Open ERP) <dhr@tinyerp.com> | 2013-03-08 19:00:39 +0530 |
| commit | f26fea2a09ab5841a22c0413e6d51c932cf9cac3 (patch) | |
| tree | 08f9759cc92cff74449758e1b4d0a4c066f40a8a /addons/google_docs/static/src/js | |
| parent | 5882be5747dc1cb68c2b1b73ed224a36d815dee1 (diff) | |
[IMP]Adding virtual entry of gdoc template for a particular record to more based on filter
bzr revid: dhr@tinyerp.com-20130308133039-lme2p04ak2pviurt
Diffstat (limited to 'addons/google_docs/static/src/js')
| -rw-r--r-- | addons/google_docs/static/src/js/gdocs.js | 86 |
1 files changed, 56 insertions, 30 deletions
diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js index 1cc511ef4d9..a0f1cba3b9b 100644 --- a/addons/google_docs/static/src/js/gdocs.js +++ b/addons/google_docs/static/src/js/gdocs.js @@ -3,38 +3,64 @@ var _t = instance.web._t, QWeb = instance.web.qweb; instance.web.Sidebar.include({ - redraw: function() { + + start: function() { var self = this; + var ids 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_eval_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(); - }); - }); - } - } + var result; + if(view.fields_view.type == "form"){ + ids = [] + view.on("load_record", self, function(r){ + ids = [r.id] + self.add_gdoc_items(view,ids) + }); + } + }, + + add_gdoc_items: function(view,ids){ + $('.oe_share_gdoc').remove(); + var self = this; + if( !_.isEmpty(ids) ){ + view.sidebar_eval_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) { + console.log("thjoid ",self.items['other']) + if(!_.isEmpty(r)){ + _.each(r,function(res){ + _.each(self.items['other'],function(others){ + if(others['label'] == res){ + self.items['other'].pop() + } + }) + self.add_items('other', [ + { label: res, + callback: self.on_google_doc, + classname: 'oe_share_gdoc' }, + ]); + }) + } + }); + }); + } + }, + + on_google_doc: function(r) { + 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_eval_context().done(function (context) { + var ds = new instance.web.DataSet(this, 'ir.attachment', context); + ds.call('get_attachment', [view.dataset.model, r, ids, context]).done(function(res) { + console.log('resssssss',res) + window.open(res.url,"_blank"); + view.reload(); + }) + + }); + } + } }); }; |
