2012-05-22 13:39:44 +00:00
|
|
|
openerp.google_docs = function(instance, m) {
|
2012-10-12 13:53:42 +00:00
|
|
|
var QWeb = instance.web.qweb,
|
|
|
|
_t = instance.web._t;
|
2012-05-23 09:51:36 +00:00
|
|
|
|
2012-05-22 13:39:44 +00:00
|
|
|
instance.web.Sidebar = instance.web.Sidebar.extend({
|
2012-10-12 13:53:42 +00:00
|
|
|
redraw: function() {
|
|
|
|
var self = this;
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
self.$el.find('.oe_sidebar_add_attachment').after(QWeb.render('Google_doc', {widget: self}))
|
|
|
|
self.$el.find('.oe_sidebar_add_google_doc').on('click', function (e) {
|
|
|
|
self.on_google_doc();
|
2012-05-23 09:51:36 +00:00
|
|
|
});
|
2012-05-22 13:39:44 +00:00
|
|
|
},
|
|
|
|
on_google_doc: function() {
|
|
|
|
var self = this;
|
|
|
|
var form = self.getParent();
|
|
|
|
form.sidebar_context().then(function (context) {
|
2012-05-23 09:51:36 +00:00
|
|
|
var ds = new instance.web.DataSet(this, 'ir.attachment', context);
|
2012-10-12 13:53:42 +00:00
|
|
|
def = ds.call('google_doc_get', [form.dataset.model, [form.datarecord.id], context], function(r) {
|
2012-04-02 13:18:17 +00:00
|
|
|
if (r == 'False') {
|
|
|
|
var params = {
|
|
|
|
error: response,
|
2012-05-23 09:51:36 +00:00
|
|
|
message: _t("The user google credentials are not set yet. Contact your administrator for help.")
|
2012-04-02 13:18:17 +00:00
|
|
|
}
|
|
|
|
$(openerp.web.qweb.render("DialogWarning", params)).dialog({
|
2012-05-23 09:51:36 +00:00
|
|
|
title: _t("User Google credentials are not yet set."),
|
2012-04-02 13:18:17 +00:00
|
|
|
modal: true,
|
|
|
|
});
|
|
|
|
}
|
2012-10-12 13:53:42 +00:00
|
|
|
|
|
|
|
}).done(function(){
|
|
|
|
form.reload();
|
|
|
|
});
|
2012-05-23 09:51:36 +00:00
|
|
|
})
|
2012-05-22 13:39:44 +00:00
|
|
|
}
|
2012-05-23 09:51:36 +00:00
|
|
|
})
|
|
|
|
}
|