1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
24 import openerp.addons.web.common.http as openerpweb
27 import web.common.http as openerpweb
31 from osv import osv, fields
33 class Binary(openerpweb.Controller):
34 _cp_path = "/web_linkedin/binary"
36 @openerpweb.jsonrequest
37 def url2binary(self, req,url):
38 bfile = urllib2.urlopen(url)
39 return base64.b64encode(bfile.read())
41 class web_linkedin_settings(osv.osv_memory):
42 _inherit = 'sale.config.settings'
44 'api_key': fields.char(string="API Key", size=50),
45 'server_domain': fields.char(size=100),
48 def get_default_linkedin(self, cr, uid, fields, context=None):
49 key = self.pool.get("ir.config_parameter").get_param(cr, uid, "web.linkedin.apikey") or ""
50 dom = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
51 return {'api_key': key, 'server_domain': dom,}
53 def set_linkedin(self, cr, uid, ids, context=None):
54 key = self.browse(cr, uid, ids[0], context)["api_key"] or ""
55 self.pool.get("ir.config_parameter").set_param(cr, uid, "web.linkedin.apikey", key)