1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# This module Copyright (C) 2012 OpenUpgrade community
6
# https://launchpad.net/~openupgrade-committers
9
# Therp BV <http://therp.nl>
11
# This program is free software: you can redistribute it and/or modify
12
# it under the terms of the GNU Affero General Public License as
13
# published by the Free Software Foundation, either version 3 of the
14
# License, or (at your option) any later version.
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU Affero General Public License for more details.
21
# You should have received a copy of the GNU Affero General Public License
22
# along with this program. If not, see <http://www.gnu.org/licenses/>.
24
##############################################################################
26
from osv import osv, fields
28
from tools.translate import _
30
class openupgrade_comparison_config(osv.osv):
31
_name = 'openupgrade.comparison.config'
33
'name': fields.char('Name', size=64),
34
'server': fields.char('Server', size=64, required=True),
35
'port': fields.integer('Port', required=True),
36
'protocol': fields.selection(
37
[('http://', 'XML-RPC')],
38
# ('https://', 'XML-RPC Secure')], not supported by libopenerp
39
'Protocol', required=True),
40
'database': fields.char('Database', size=64, required=True),
41
'username': fields.char('Username', size=24, required=True),
42
'password': fields.char('Password', size=24, required=True, password=True),
43
'last_log': fields.text('Last log'),
46
'port': lambda *a: 8069,
47
'protocol': lambda *a: 'http://',
50
def get_connection(self, cr, uid, ids, context=None):
53
_("Cannot connect"), _("Invalid id passed."))
54
conf = self.read(cr, uid, ids[0], context=None)
55
return openerplib.get_connection(
56
hostname=conf['server'],
57
database=conf['database'],
58
login=conf['username'],
59
password=conf['password'],
63
def test_connection(self, cr, uid, ids, context=None):
65
connection = self.get_connection(cr, uid, [ids[0]], context)
66
user_model = connection.get_model("res.users")
67
ids = user_model.search([("login", "=", "admin")])
68
user_info = user_model.read(ids[0], ["name"])
71
_("Connection failed."), unicode(e))
73
_("Connection succesful."),
74
_("%s is connected.") % user_info["name"]
77
def analyze(self, cr, uid, ids, context=None):
79
Run the analysis wizard
81
wizard_obj = self.pool.get('openupgrade.analysis.wizard')
82
wizard_id = wizard_obj.create(
83
cr, uid, {'server_config': ids[0]}, context)
85
'name': wizard_obj._description,
88
'res_model': 'openupgrade.analysis.wizard',
91
'type': 'ir.actions.act_window',
98
openupgrade_comparison_config()