diff --git a/addons/google_docs/__openerp__.py b/addons/google_docs/__openerp__.py index fcbc008fd36..6b7f28116ec 100644 --- a/addons/google_docs/__openerp__.py +++ b/addons/google_docs/__openerp__.py @@ -20,7 +20,7 @@ ############################################################################## { - 'name': 'Google Drive integration', + 'name': 'Google Driveā„¢ integration', 'version': '0.2', 'author': 'OpenERP SA', 'website': 'http://openerp.com', 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): diff --git a/addons/google_docs/static/src/img/icon.png b/addons/google_docs/static/src/img/icon.png index e7f64291ef9..3989ab57b30 100644 Binary files a/addons/google_docs/static/src/img/icon.png and b/addons/google_docs/static/src/img/icon.png differ diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js index 505815f4b2e..9d15cb37a2b 100644 --- a/addons/google_docs/static/src/js/gdocs.js +++ b/addons/google_docs/static/src/js/gdocs.js @@ -34,7 +34,7 @@ openerp.google_docs = function (instance, m) { self.items.other.splice(g_item, 1); } self.add_items('other', [{ - label: res.name+ '', + label: res.name+ '', config_id: res.id, res_id: res_id, res_model: view.dataset.model,