diff options
| author | Vijaykumar Baladaniya <vba@tinyerp.com> | 2012-10-15 11:44:32 +0530 |
|---|---|---|
| committer | Vijaykumar Baladaniya <vba@tinyerp.com> | 2012-10-15 11:44:32 +0530 |
| commit | eb0b0650c435feef106c1e22de65e217111ee1b2 (patch) | |
| tree | 60dfea6ac9f8709f7fea23e51ff34b3022d588fd /addons/google_docs | |
| parent | 2c6281b4fb1c1512c4bdeb5e70c7e17fd73c5a67 (diff) | |
| parent | 81b2e5c8ae46d795bf6e0cb7fc620d60f5c5b291 (diff) | |
[MERGE]Merge with trunk-google-doc-imp-rga.
bzr revid: vba@tinyerp.com-20121015061432-ugrpvdx98k2n7q4e
Diffstat (limited to 'addons/google_docs')
| -rw-r--r-- | addons/google_docs/__openerp__.py | 2 | ||||
| -rw-r--r-- | addons/google_docs/google_docs.py | 5 | ||||
| -rw-r--r-- | addons/google_docs/res_config_user_view.xml | 29 | ||||
| -rw-r--r-- | addons/google_docs/static/src/js/gdocs.js | 30 | ||||
| -rw-r--r-- | addons/google_docs/static/src/xml/gdocs.xml | 8 |
5 files changed, 48 insertions, 26 deletions
diff --git a/addons/google_docs/__openerp__.py b/addons/google_docs/__openerp__.py index b02f2e912fc..716a603043d 100644 --- a/addons/google_docs/__openerp__.py +++ b/addons/google_docs/__openerp__.py @@ -27,8 +27,8 @@ 'category': 'Tools', 'installable': True, 'auto_install': False, - 'web': True, 'js': ['static/src/js/gdocs.js'], + 'qweb': ['static/src/xml/gdocs.xml'], 'data': [ 'security/ir.model.access.csv', 'res_config_user_view.xml' diff --git a/addons/google_docs/google_docs.py b/addons/google_docs/google_docs.py index 76530c1290c..47029e78210 100644 --- a/addons/google_docs/google_docs.py +++ b/addons/google_docs/google_docs.py @@ -26,8 +26,11 @@ try: from gdata.client import RequestError from gdata.docs.service import DOCUMENT_LABEL import gdata.auth + from gdata.docs.data import Resource except ImportError: - raise osv.except_osv(_('Google Docs Error!'), _('Please install gdata-python-client from http://code.google.com/p/gdata-python-client/downloads/list.')) + import logging + _logger = logging.getLogger(__name__) + _logger.warning("Please install latest gdata-python-client from http://code.google.com/p/gdata-python-client/downloads/list") class google_docs_ir_attachment(osv.osv): _inherit = 'ir.attachment' diff --git a/addons/google_docs/res_config_user_view.xml b/addons/google_docs/res_config_user_view.xml index 4aabba3ac5a..e6c4223735f 100644 --- a/addons/google_docs/res_config_user_view.xml +++ b/addons/google_docs/res_config_user_view.xml @@ -8,9 +8,10 @@ <field name="name">google_docs.config.tree</field> <field name="model">google.docs.config</field> <field name="arch" type="xml"> - <group name="default_filters" position="inside"> + <tree string="Google Docs Configuration"> <field name="model_id"/> - </group> + <field name="name_template"/> + </tree> </field> </record> @@ -18,11 +19,25 @@ <field name="name">google_docs.config.form</field> <field name="model">google.docs.config</field> <field name="arch" type="xml"> - <group colspan='4'> - <field name="model_id"/> - <field name='gdocs_resource_id'/> - <field name='name_template'/> - </group> + <form string="Google Docs Configuration" version="7.0"> + <group> + <field name="model_id"/> + <label for='gdocs_resource_id'/> + <div> + <field name='gdocs_resource_id'/> + <p class="oe_grey"> +This is the id of the template document, on google side. You can find it thanks to its URL: +<ul> +<li>for a text document with url like `https://docs.google.com/a/openerp.com/document/d/123456789/edit`, the ID is `document:123456789`</li> +<li>for a spreadsheet document with url like `https://docs.google.com/a/openerp.com/spreadsheet/ccc?key=123456789#gid=0`, the ID is `spreadsheet:123456789`</li> +<li>for a presentation (slide show) document with url like `https://docs.google.com/a/openerp.com/presentation/d/123456789/edit#slide=id.p`, the ID is `presentation:123456789`</li> +<li>for a drawing document with url like `https://docs.google.com/a/openerp.com/drawings/d/123456789/edit`, the ID is `drawings:123456789`</li> +</ul> + </p> + </div> + <field name='name_template'/> + </group> + </form> </field> </record> diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js index bcfd24f8c0d..c2c0ded407b 100644 --- a/addons/google_docs/static/src/js/gdocs.js +++ b/addons/google_docs/static/src/js/gdocs.js @@ -1,28 +1,22 @@ openerp.google_docs = function(instance, m) { -var _t = instance.web._t; +var QWeb = instance.web.qweb, + _t = instance.web._t; instance.web.Sidebar = instance.web.Sidebar.extend({ - on_attachments_loaded: function(attachments) { - var self = this; - self._super(attachments); - // if attachment contains a google doc url do nothing - // else display a button to create a google doc - var flag = false; - _.each(attachments, function(i) { - if (i.url && i.url.match('/docs.google.com/')) { flag = true; } + 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(); }); - if (! flag) { - this.add_items('files', [ - { label: _t('Add 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, 'ir.attachment', context); - ds.call('google_doc_get', [form.dataset.model, [form.datarecord.id], context], function(r) { + def = ds.call('google_doc_get', [form.dataset.model, [form.datarecord.id], context], function(r) { if (r == 'False') { var params = { error: response, @@ -33,8 +27,10 @@ var _t = instance.web._t; modal: true, }); } - form.reload(); - }); + + }).done(function(){ + form.reload(); + }); }) } }) 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..85a3b3f8be0 --- /dev/null +++ b/addons/google_docs/static/src/xml/gdocs.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- vim:fdl=1: +--> +<templates id="template" xml:space="preserve"> +<t t-name="Google_doc"> + <li class="oe_sidebar_add_google_doc"><span><b>Add Google Doc...</b></span></li> +</t> +</templates>
\ No newline at end of file |
