}
},
- add_gdoc_items: function(view,ids){
- $('.oe_share_gdoc').remove();
+ add_gdoc_items: function(view,ids){
var self = this;
+ var gdoc_item = _.indexOf(_.pluck(self.items.other,'classname'),'oe_share_gdoc');
+ if(gdoc_item !== -1)
+ {
+ self.items.other.splice(gdoc_item,1);
+ }
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()
- }
- })
+ var g_item = _.indexOf(_.pluck(self.items.other,'label'),res);
+ if(g_item !== -1)
+ {
+ self.items.other.splice(g_item,1);
+ }
+
self.add_items('other', [
{ label: res,
callback: self.on_google_doc,
}
},
+
on_google_doc: function(r) {
var self = this;
var view = self.getParent();
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();
})