Add UpdatableDict for wizard partial picking
bzr revid: ced-3ddd65392ce2656864c58a4ccf04a5fa947ce9b5
This commit is contained in:
parent
1a7db4943c
commit
0955ee2794
|
@ -325,8 +325,111 @@ class UpdateableStr(local):
|
|||
def __nonzero__(self):
|
||||
return bool(self.string)
|
||||
|
||||
|
||||
class UpdateableDict(local):
|
||||
'''Stores an updateable dict to use in wizards'''
|
||||
|
||||
def __init__(self, dict=None):
|
||||
if dict is None:
|
||||
dict = {}
|
||||
self.dict = dict
|
||||
|
||||
def __str__(self):
|
||||
return str(self.dict)
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.dict)
|
||||
|
||||
def clear(self):
|
||||
return self.dict.clear()
|
||||
|
||||
def keys(self):
|
||||
return self.dict.keys()
|
||||
|
||||
def __setitem__(self, i, y):
|
||||
self.dict.__setitem__(i, y)
|
||||
|
||||
def __getitem__(self, i):
|
||||
return self.dict.__getitem__(i)
|
||||
|
||||
def copy(self):
|
||||
return self.dict.copy()
|
||||
|
||||
def iteritems(self):
|
||||
return self.dict.iteritems()
|
||||
|
||||
def iterkeys(self):
|
||||
return self.dict.iterkeys()
|
||||
|
||||
def itervalues(self):
|
||||
return self.dict.itervalues()
|
||||
|
||||
def pop(self, k, d=None):
|
||||
return self.dict.pop(k, d)
|
||||
|
||||
def popitem(self):
|
||||
return self.dict.popitem()
|
||||
|
||||
def setdefault(self, k, d=None):
|
||||
return self.dict.setdefault(k, d)
|
||||
|
||||
def update(self, E, **F):
|
||||
return self.dict.update(E, F)
|
||||
|
||||
def values(self):
|
||||
return self.dict.values()
|
||||
|
||||
def get(self, k, d=None):
|
||||
return self.dict.get(k, d)
|
||||
|
||||
def has_key(self, k):
|
||||
return self.dict.has_key(k)
|
||||
|
||||
def items(self):
|
||||
return self.dict.items()
|
||||
|
||||
def __cmp__(self, y):
|
||||
return self.dict.__cmp__(y)
|
||||
|
||||
def __contains__(self, k):
|
||||
return self.dict.__contains__(k)
|
||||
|
||||
def __delitem__(self, y):
|
||||
return self.dict.__delitem__(y)
|
||||
|
||||
def __eq__(self, y):
|
||||
return self.dict.__eq__(y)
|
||||
|
||||
def __ge__(self, y):
|
||||
return self.dict.__ge__(y)
|
||||
|
||||
def __getitem__(self, y):
|
||||
return self.dict.__getitem__(y)
|
||||
|
||||
def __gt__(self, y):
|
||||
return self.dict.__gt__(y)
|
||||
|
||||
def __hash__(self):
|
||||
return self.dict.__hash__()
|
||||
|
||||
def __iter__(self):
|
||||
return self.dict.__iter__()
|
||||
|
||||
def __le__(self, y):
|
||||
return self.dict.__le__(y)
|
||||
|
||||
def __len__(self):
|
||||
return self.dict.__len__()
|
||||
|
||||
def __lt__(self, y):
|
||||
return self.dict.__lt__(y)
|
||||
|
||||
def __ne__(self, y):
|
||||
return self.dict.__ne__(y)
|
||||
|
||||
|
||||
# Don't use ! Use res.currency.round()
|
||||
class currency(float):
|
||||
class currency(float):
|
||||
|
||||
def __init__(self, value, accuracy=2, rounding=None):
|
||||
if rounding is None:
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
import netsvc
|
||||
import copy
|
||||
from tools.misc import UpdateableStr
|
||||
from tools.misc import UpdateableStr, UpdateableDict
|
||||
from tools.translate import translate
|
||||
from xml import dom
|
||||
|
||||
|
@ -90,6 +90,11 @@ class interface(netsvc.Service):
|
|||
arch = copy.copy(result_def['arch'])
|
||||
button_list = copy.copy(result_def['state'])
|
||||
|
||||
if isinstance(fields, UpdateableDict):
|
||||
fields = fields.dict
|
||||
if isinstance(arch, UpdateableStr):
|
||||
arch = arch.string
|
||||
|
||||
# fetch user-set defaut values for the field... shouldn't we pass it the uid?
|
||||
defaults = ir.ir_get(cr, uid, 'default', False, [('wizard.'+self.wiz_name, False)])
|
||||
default_values = dict([(x[1], x[2]) for x in defaults])
|
||||
|
@ -110,9 +115,6 @@ class interface(netsvc.Service):
|
|||
fields[val] = copy.copy(fields[val])
|
||||
fields[val]['selection'] = fields[val]['selection'](self, cr, uid, context)
|
||||
|
||||
if isinstance(arch, UpdateableStr):
|
||||
arch = arch.string
|
||||
|
||||
if lang:
|
||||
# translate fields
|
||||
for field in fields:
|
||||
|
|
Loading…
Reference in New Issue