1035.1.4
by jf
[IMP] Instance / CoA: new installer |
1 |
# -*- coding: utf-8 -*-
|
2 |
||
3 |
from osv import fields, osv |
|
4 |
import tools |
|
5 |
from os.path import join as opj |
|
6 |
from tools.translate import _ |
|
7 |
||
8 |
||
9 |
class msf_instance_setup(osv.osv_memory): |
|
10 |
_name = 'msf_instance.setup' |
|
11 |
_inherit = 'res.config' |
|
12 |
||
13 |
_columns = { |
|
14 |
'instance_id': fields.many2one('msf.instance', string="Proprietary instance", required=True), |
|
15 |
}
|
|
16 |
||
17 |
def get_instance(self, cr, uid, context=None): |
|
18 |
instance_ids = self.pool.get('msf.instance').search(cr, uid, [], limit=1) |
|
19 |
return instance_ids and instance_ids[0] or False |
|
20 |
||
21 |
_defaults = { |
|
22 |
'instance_id': get_instance, |
|
23 |
}
|
|
24 |
||
25 |
def execute(self, cr, uid, ids, context=None): |
|
26 |
res = self.read(cr, uid, ids) |
|
27 |
self.pool.get('res.company').write(cr, uid, [self.pool.get('res.users').browse(cr, uid, uid).company_id.id], {'instance_id': res[0]['instance_id']}) |
|
28 |
return {} |
|
29 |
||
30 |
msf_instance_setup() |