diff --git a/addons/google_docs/__openerp__.py b/addons/google_docs/__openerp__.py index 991a3e07e2c..2461be1e151 100644 --- a/addons/google_docs/__openerp__.py +++ b/addons/google_docs/__openerp__.py @@ -1,6 +1,18 @@ { 'name': 'Wiki', 'version': '0.1', + 'author': 'OpenERP SA', + 'website': 'http://openerp.com', + 'data': [ + 'res_gdocs.xml' + ], + 'installable': True, + 'auto_install': False, + 'web': True, + 'js': ['static/src/js/gdocs.js'], + 'qweb' : [ + "static/src/xml/*.xml", + ], 'depends': ['google_base_account'], 'description': 'Module to attach a google document to any model.' } diff --git a/addons/google_docs/res_company.xml b/addons/google_docs/res_gdocs.xml similarity index 91% rename from addons/google_docs/res_company.xml rename to addons/google_docs/res_gdocs.xml index 0324039c8f2..b1a54fdc63e 100644 --- a/addons/google_docs/res_company.xml +++ b/addons/google_docs/res_gdocs.xml @@ -2,7 +2,7 @@ res.company.form.gdocs - res.company + google.docs form diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js new file mode 100644 index 00000000000..e605577d45a --- /dev/null +++ b/addons/google_docs/static/src/js/gdocs.js @@ -0,0 +1,29 @@ +openerp.gdocs = function(instance) { + +instance.web.form.SidebarAttachments = instance.web.form.SidebarAttachments.extend({ + on_attachments_loaded: function(attachments) { + this._super(attachments); + var self = this; + var $padbtn = self.$element.find('button.gdocs'); + var is_pad = function(a) { + return a.type == 'url' && a.name == 'GDocs'; + }; + if (_.any(attachments, is_pad)) { + $padbtn.hide(); + } else { + $padbtn.show().click(self.on_add_pad); + } + }, + on_add_pad: function() { + var self = this; + var $padbtn = this.$element.find('button.gdocs'); + $padbtn.attr('disabled', 'true').find('img, span').toggle(); + this.view.dataset.call_button('pad_get', [[this.view.datarecord.id], this.view.dataset.get_context()], function(r) { + $padbtn.hide(); + self.do_update(); + self.do_action(r.result); + }); + } +}); + +}; diff --git a/addons/google_docs/static/src/xml/gdocs.xml b/addons/google_docs/static/src/xml/gdocs.xml new file mode 100644 index 00000000000..52decbfdbc1 --- /dev/null +++ b/addons/google_docs/static/src/xml/gdocs.xml @@ -0,0 +1,13 @@ + + + + + + + + +