1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 MSF, TeMPO consulting
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
from tools.translate import _
import base64
from os.path import join as opj
import tools
class ir_model_data(osv.osv):
_inherit = 'ir.model.data'
_name = 'ir.model.data'
def _update(self,cr, uid, model, module, values, xml_id=False, store=True, noupdate=False, mode='init', res_id=False, context=None):
"""
Store in context that we came from _update
"""
if not context:
context = {}
ctx = context.copy()
ctx['update_mode'] = mode
return super(ir_model_data, self)._update(cr, uid, model, module, values, xml_id, store, noupdate, mode, res_id, ctx)
ir_model_data()
class account_installer(osv.osv_memory):
_inherit = 'account.installer'
_name = 'account.installer'
_defaults = {
'charts': 'msf_chart_of_account',
}
account_installer()
class res_config_view(osv.osv_memory):
_inherit = 'res.config.view'
_name = 'res.config.view'
_defaults={
'view': 'extended',
}
res_config_view()
class base_setup_company(osv.osv_memory):
_inherit = 'base.setup.company'
_name = 'base.setup.company'
def default_get(self, cr, uid, fields_list=None, context=None):
ret = super(base_setup_company, self).default_get(cr, uid, fields_list, context)
if not ret.get('name'):
ret.update({'name': 'MSF', 'street': 'Rue de Lausanne 78', 'street2': 'CP 116', 'city': 'Geneva', 'zip': '1211', 'phone': '+41 (22) 849.84.00'})
cur = self.pool.get('res.currency').search(cr, uid, [('name','=','EUR')])
if cur:
ret['currency'] = cur[0]
country = self.pool.get('res.country').search(cr, uid, [('name','=','Switzerland')])
if country:
ret['country_id'] = country[0]
fp = tools.file_open(opj('msf_profile', 'data', 'msf.jpg'))
ret['logo'] = base64.encodestring(fp.read())
fp.close()
return ret
base_setup_company()
|