diff options
| author | Parth Gajjar (Open ERP) <pga@tinyerp.com> | 2013-05-29 12:37:23 +0530 |
|---|---|---|
| committer | Parth Gajjar (Open ERP) <pga@tinyerp.com> | 2013-05-29 12:37:23 +0530 |
| commit | 0fec1053f3ef27da8e09d54d6ba5817ab716eb32 (patch) | |
| tree | c416f2e55c84a03ade7b2143abac7b0a9e334455 /addons/google_docs/google_docs.py | |
| parent | ffcc15c7e1d93ed4042807bddfc578b70c80e8d4 (diff) | |
[IMP] Added alert, Changed logo
bzr revid: pga@tinyerp.com-20130529070723-ruz42rqh798h4w0a
Diffstat (limited to 'addons/google_docs/google_docs.py')
| -rw-r--r-- | addons/google_docs/google_docs.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/addons/google_docs/google_docs.py b/addons/google_docs/google_docs.py index 932f8658627..e97f0d929f1 100644 --- a/addons/google_docs/google_docs.py +++ b/addons/google_docs/google_docs.py @@ -84,18 +84,23 @@ class config(osv.osv): content = json.loads(content) # Copy template in to drive with help of new access token - headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} - record_url = "Click on link to open Record in OpenERP\n %s/?db=%s#id=%s&model=%s" %(google_web_base_url, cr.dbname, res_id, res_model ) - data = {"title": name_gdocs, "description": record_url} - request_url = "https://www.googleapis.com/drive/v2/files/%s/copy?access_token=%s" % (tamplate_id, content['access_token']) - resp, content = Http().request(request_url, "POST", json.dumps(data), headers) - content = json.loads(content) - res = False - if 'alternateLink' in content.keys(): - attach_pool = self.pool.get("ir.attachment") - attach_vals = {'res_model': res_model, 'name': name_gdocs, 'res_id': res_id, 'type': 'url', 'url':content['alternateLink']} - attach_pool.create(cr, uid, attach_vals) - res = content['alternateLink'] + if content.has_key('access_token'): + headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} + record_url = "Click on link to open Record in OpenERP\n %s/?db=%s#id=%s&model=%s" %(google_web_base_url, cr.dbname, res_id, res_model ) + data = {"title": name_gdocs, "description": record_url} + request_url = "https://www.googleapis.com/drive/v2/files/%s/copy?access_token=%s" % (tamplate_id, content['access_token']) + resp, content = Http().request(request_url, "POST", json.dumps(data), headers) + content = json.loads(content) + res = False + if 'alternateLink' in content.keys(): + attach_pool = self.pool.get("ir.attachment") + attach_vals = {'res_model': res_model, 'name': name_gdocs, 'res_id': res_id, 'type': 'url', 'url':content['alternateLink']} + attach_pool.create(cr, uid, attach_vals) + res = content['alternateLink'] + elif uid==1: + raise self.pool.get('res.config.settings').get_config_warning(cr, _("You haven't configured 'Authorization Code' generated from google, Please generate and configure it in %%(menu:base_setup.menu_general_configuration)s."), context=context) + else: + raise osv.except_osv(_('Google Drive Configuration Error!'), _("'Authorization Code' is not configured yet, Please Contact Administrator")) return res def get_google_docs_config(self, cr, uid, res_model, res_id, context=None): |
