From 95a86ec57dfb22569ed9b1bd8ea36ae44f9e6856 Mon Sep 17 00:00:00 2001 From: MVA Date: Wed, 28 Mar 2012 13:41:13 +0200 Subject: [IMP] add some comment and add a raise if the google resource is not correct bzr revid: mva@openerp.com-20120328114113-vspkkbvpdfnt3mho --- addons/google_docs/google_docs.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'addons/google_docs/google_docs.py') diff --git a/addons/google_docs/google_docs.py b/addons/google_docs/google_docs.py index 1e6071cd716..6e91ee64658 100644 --- a/addons/google_docs/google_docs.py +++ b/addons/google_docs/google_docs.py @@ -76,13 +76,18 @@ class google_docs_ir_attachment(osv.osv): return 1 def copy_gdoc(self, cr, uid, model, google_res_id, ids,context=None): + ''' + copy an existing document in google docs + ''' + client = self._auth(cr, uid) # fetch and copy the original document - print 'test' - original_resource = client.get_resource_by_id(google_res_id) - #copy the document you choose in the configuration - copy_resource = client.copy_resource(original_resource,'copy_%s' % original_resource.title.text) - + try: + original_resource = client.get_resource_by_id(google_res_id) + #copy the document you choose in the configuration + copy_resource = client.copy_resource(original_resource,'copy_%s' % original_resource.title.text) + except: + raise osv.except_osv(('Google Docs Error!'),("Your ressource id is not correct. You can find the id in the google docs URL") ) # register into the db self.create(cr, uid, { 'res_model': model, @@ -126,6 +131,10 @@ class config(osv.osv): 'context_name': 'pr_%(name)', } def get_config(self, cr, uid, model): + ''' + Method use with the js to hidde or show the add google doc button + @return : list of configuration ids or false + ''' domain = [('context_model_id', '=', model)] if self.search_count(cr, uid, domain) != 0: return False -- cgit v1.2.3