1
###############################################################################
3
# Copyright (C) 2007-TODAY Tiny ERP Pvt Ltd. All Rights Reserved.
7
# Developed by Tiny (http://openerp.com) and Axelor (http://axelor.com).
9
# The OpenERP web client is distributed under the "OpenERP Public License".
10
# It's based on Mozilla Public License Version (MPL) 1.1 with following
13
# - All names, links and logos of Tiny, Open ERP and Axelor must be
14
# kept as in original distribution without any changes in all software
15
# screens, especially in start-up page and the software header, even if
16
# the application source code has been changed or updated or code has been
19
# - All distributions of the software must keep source code with OEPL.
21
# - All integrations to any other software must keep source code with OEPL.
23
# If you need commercial licence to remove this kind of restriction please
26
# You can see the MPL licence at: http://www.mozilla.org/MPL/MPL-1.1.html
28
###############################################################################
33
from openerp.tools import expose
37
from openerp import rpc
38
from openerp import tools
39
from openerp import common
41
from openerp.controllers.base import SecuredController
43
from openerp.utils import TinyDict
44
from openerp.utils import TinyForm
46
import openerp.widgets as tw
48
class FieldPref(SecuredController):
50
@expose(template="templates/fieldpref.mako")
51
def index(self, **kw): #_terp_model, _terp_field, _terp_deps
54
params, data = TinyDict.split(kw)
56
return dict(model=params.model, click_ok=click_ok, field=params.field, deps=params.deps)
60
params, data = TinyDict.split(kw)
62
field = params.field.split('/')
64
prefix = '.'.join(field[:-1])
67
pctx = TinyForm(**kw).to_python(safe=True)
68
ctx = pctx.chain_get(prefix) or pctx
70
proxy = rpc.RPCProxy(params.model)
71
res = proxy.fields_get(False, rpc.session.context)
73
text = res[field].get('string')
76
for name, attrs in res.items():
77
if attrs.get('change_default', False):
80
deps.append((name, name, value, value))
82
return dict(text=text, deps=str(deps))
84
@expose(template="templates/fieldpref.mako")
86
params, data = TinyDict.split(kw)
90
for n, v in params.deps.items():
95
field = params.field['name']
96
value = params.field['value']
99
field = field.split('/')[-1]
101
proxy = rpc.RPCProxy('ir.values')
103
if type(value) == type('') and not len(value):
106
res = proxy.set('default', deps, field, [(model,False)], value, True, False, False, params.you or False, True)
108
return dict(model=params.model, click_ok=click_ok, field=params.field, deps=params.deps2, should_close=True)
110
# vim: ts=4 sts=4 sw=4 si et