forked from factorlibre/delivery-carrier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
64 lines (58 loc) · 2.56 KB
/
config.py
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
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) All Rights Reserved 2014 Akretion
# @author David BEAL <[email protected]>
#
# 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 openerp.osv import orm, fields
from . company import ResCompany
class GlsConfigSettings(orm.TransientModel):
_name = 'gls.config.settings'
_description = 'GLS carrier configuration'
_inherit = ['res.config.settings', 'abstract.config.settings']
_prefix = 'gls_'
_companyObject = ResCompany
_columns = {
'gls_customer_code': fields.char(
string='Customer Code',
readonly=True,
help="Code for GLS carrier company (T8915)\n"
"Information common to whole companies "
"to configure in System Parameter"),
'gls_warehouse': fields.char(
string='Warehouse',
readonly=True,
help="GLS warehouse near customer location (T8700)\n"
"Information common to whole companies "
"to configure in System Parameter"),
}
def default_get(self, cr, uid, fields, context=None):
res = {}
param_m = self.pool['ir.config_parameter']
for field in ['gls_customer_code', 'gls_warehouse']:
if field in fields:
ids = param_m.search(
cr, uid, [('key', '=', 'carrier_%s' % field)],
context=context)
if not ids:
raise orm.except_orm(
"Missing parameter",
"'%s' key is missing in 'System Parameter':\n"
"Add it and set the corresponding value" % field)
param = param_m.browse(cr, uid, ids, context=context)[0]
res[field] = param.value
return res