Handle on_change_with
This commit is contained in:
1 parent
c2424a73e1
commit
28371360d1
2 files changed
+25
No files matched your search
@@ -35,6 +35,7 @@ class CharField(object):
|
||||
model.on_change(self.name, self.attrs['on_change'])
|
||||
if self.attrs.get('change_default', False):
|
||||
model.cond_default(self.attrs['name'], self.get(model))
|
||||
model.on_change_with(self.name)
|
||||
|
||||
def domain_get(self, model):
|
||||
dom = self.attrs.get('domain', '[]')
|
||||
|
||||
@@ -314,6 +314,30 @@ class ModelRecord(SignalEvent):
|
||||
self.mgroup.mfields[fieldname].set_on_change(self, value)
|
||||
self.signal('record-changed')
|
||||
|
||||
def on_change_with(self, fieldname):
|
||||
for fieldname in self.mgroup.mfields:
|
||||
on_change_with = self.mgroup.mfields[fieldname].attrs.get(
|
||||
'on_change_with')
|
||||
if not on_change_with:
|
||||
continue
|
||||
args = {}
|
||||
for arg in on_change_with:
|
||||
try:
|
||||
args[arg] = self.expr_eval(arg)
|
||||
except:
|
||||
args[arg] = False
|
||||
ids = self.id and [self.id] or []
|
||||
ctx = rpc.CONTEXT.copy()
|
||||
ctx.update(self.context_get())
|
||||
try:
|
||||
res = getattr(self.rpc, 'on_change_with_' + fieldname)(ids,
|
||||
args, ctx)
|
||||
except Exception, exception:
|
||||
common.process_exception(exception, self.window)
|
||||
res = getattr(self.rpc, 'on_change_with_' + fieldname)(ids,
|
||||
args, ctx)
|
||||
self.mgroup.mfields[fieldname].set_on_change(self, res)
|
||||
|
||||
def cond_default(self, field_name, value):
|
||||
ir_default = RPCProxy('ir.default')
|
||||
ctx = rpc.CONTEXT.copy()
|
||||
|
||||
Reference in new issue
Block a user