[fix] fix according to requirements
bzr revid: rlo@openerp.com-20120316090054-0datu37ojj98lx13
This commit is contained in:
@@ -106,7 +106,7 @@ class google_docs_ir_attachment(osv.osv):
|
||||
class google_docs(osv.osv):
|
||||
_name = 'google.docs'
|
||||
|
||||
def doc_get(self, cr, uid, model, id, type_doc):# TODO fix logic here
|
||||
def doc_get(self, cr, uid, model, id, type_doc):
|
||||
google_docs_config_ref = self.pool.get('res.users')
|
||||
ir_attachment_ref = self.pool.get('ir.attachment')
|
||||
google_docs_config = google_docs_config_ref.search(cr, uid, [('context_model_id', '=', model)])
|
||||
@@ -139,11 +139,11 @@ class config(osv.osv):
|
||||
'context_multiple': False,
|
||||
}
|
||||
|
||||
def has_config_set(self, cr, uid, model):
|
||||
print model
|
||||
import pdb
|
||||
pdb.set_trace()
|
||||
def get_config(self, cr, uid, model):
|
||||
domain = [('context_model_id', '=', model)]
|
||||
return self.search_count(cr, uid, domain) != 0
|
||||
if self.search_count(cr, uid, domain) != 0:
|
||||
return False
|
||||
else:
|
||||
return self.search(cr, uid, domain)
|
||||
|
||||
config()
|
||||
|
||||
@@ -4,11 +4,24 @@ openerp.google_docs = function(instance, session) {
|
||||
instance.web.form.SidebarAttachments = instance.web.form.SidebarAttachments.extend({
|
||||
init: function() {
|
||||
this._super.apply(this, arguments);
|
||||
this.$element.delegate('.oe_google_docs_text_button', 'click', this.on_add_text_gdoc);
|
||||
this.$element.delegate('.oe_google_docs_spreadsheet_button', 'click', this.on_add_spreadsheet_gdoc);
|
||||
this.$element.delegate('.oe_google_docs_slide_button', 'click', this.on_add_slide_gdoc);
|
||||
var self = this;
|
||||
var config = new instance.web.DataSet(this, 'google.docs.config', this.view.dataset.get_context());
|
||||
config.call('get_config', [this.view.dataset.ids[this.view.dataset.index]], function(r) {
|
||||
console.log(r);
|
||||
// if the configuration isn't set, the buttons should be hidden.
|
||||
if (r==false) {
|
||||
$('.oe_google_docs_text_button').css('display', 'none');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var attachment = new instance.web.DataSet(this, 'ir.attachment', self.view.dataset.get_context());
|
||||
attachment.call('copy_gdoc', [self.view.dataset.model, [self.view.datarecord.id]], function(res) {
|
||||
console.log(res);
|
||||
});
|
||||
});
|
||||
},
|
||||
on_add_text_gdoc: function() {
|
||||
on_add_gdoc: function() {
|
||||
var self = this;
|
||||
var $gdocbtn = this.$element.find('.oe_google_docs_text_button');
|
||||
$gdocbtn.attr('disabled', 'true').find('img, span').toggle();
|
||||
@@ -28,24 +41,6 @@ openerp.google_docs = function(instance, session) {
|
||||
self.do_update();
|
||||
});
|
||||
},
|
||||
on_add_spreadsheet_gdoc: function() {
|
||||
var self = this;
|
||||
var $gdocbtn = this.$element.find('.oe_google_docs_spreadsheet_button');
|
||||
$gdocbtn.attr('disabled', 'true').find('img, span').toggle();
|
||||
var ds = new instance.web.DataSet(this, 'google.docs', this.view.dataset.get_context());
|
||||
ds.call('doc_get', [this.view.dataset.model, [this.view.datarecord.id], 'spreadsheet'], function(r) {
|
||||
self.do_update();
|
||||
});
|
||||
},
|
||||
on_add_slide_gdoc: function() {
|
||||
var self = this;
|
||||
var $gdocbtn = this.$element.find('.oe_google_docs_slide_button');
|
||||
$gdocbtn.attr('disabled', 'true').find('img, span').toggle();
|
||||
var ds = new instance.web.DataSet(this, 'google.docs', this.view.dataset.get_context());
|
||||
ds.call('doc_get', [this.view.dataset.model, [this.view.datarecord.id], 'slide'], function(r) {
|
||||
self.do_update();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user