[FIX] google docs new sidebar api
bzr revid: al@openerp.com-20120522133944-71thw8qolitv8ft8
This commit is contained in:
parent
ec668c7c4a
commit
df52a73fc7
|
@ -29,9 +29,6 @@
|
|||
'auto_install': False,
|
||||
'web': True,
|
||||
'js': ['static/src/js/gdocs.js'],
|
||||
'qweb' : [
|
||||
"static/src/xml/gdocs.xml",
|
||||
],
|
||||
'update_xml': [
|
||||
'res_config_user_view.xml'
|
||||
],
|
||||
|
|
|
@ -1,29 +1,19 @@
|
|||
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);
|
||||
},
|
||||
|
||||
|
||||
on_attachments_loaded: function(attachments) {
|
||||
this._super(attachments);
|
||||
var config = new instance.web.DataSet(this, 'google.docs.config', this.view.dataset.get_context());
|
||||
config.call('get_config', [[this.view.datarecord.id],this.view.dataset.model,this.view.dataset.get_context()], function(r) {
|
||||
if (r == false){
|
||||
$('.oe_google_docs_text_button',this.$element).hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
on_add_text_gdoc: function() {
|
||||
var self = this;
|
||||
var $gdocbtn = this.$element.find('.oe_google_docs_text_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], 'text'], function(r) {
|
||||
openerp.google_docs = function(instance, m) {
|
||||
instance.web.Sidebar = instance.web.Sidebar.extend({
|
||||
on_attachments_loaded: function(attachments) {
|
||||
self._super(attachements);
|
||||
// if attachment contains a google doc url do nothing
|
||||
// else
|
||||
this.sidebar.add_items('other', [
|
||||
{ label: _t('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, 'google.docs', context);
|
||||
ds.call('doc_get', [form.view.dataset.model, [form.view.datarecord.id], 'text'], function(r) {
|
||||
if (r == 'False') {
|
||||
var params = {
|
||||
error: response,
|
||||
|
@ -34,9 +24,8 @@ openerp.google_docs = function(instance, session) {
|
|||
modal: true,
|
||||
});
|
||||
}
|
||||
self.do_update();
|
||||
view.reload();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- vim:fdl=1:
|
||||
-->
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-extend="FormView.sidebar.attachments">
|
||||
<t t-jquery="div.oe-binary-file-set" t-operation="append">
|
||||
<button class="oe_google_docs_text_button" type="button">
|
||||
<img src="/web/static/src/img/throbber.gif" width="16" height="16" style="display: none"/>
|
||||
<span>Goole Docs</span>
|
||||
</button>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
Loading…
Reference in New Issue