~nch-openerp/openobject-client/6.1-opw-577958-nch

« back to all changes in this revision

Viewing changes to bin/widget/model/record.py

  • Committer: Naresh(OpenERP)
  • Date: 2012-07-20 07:02:32 UTC
  • mfrom: (2054.1.1 6.1-opw-381574-nch)
  • Revision ID: nch@tinyerp.com-20120720070232-7tjsvnrlr42j9wjj
[MERGE]:for on_change passing context, update that context with field context - if defined

Show diffs side-by-side

added added

removed removed

Lines of Context:
300
300
        return val
301
301
 
302
302
    #XXX Shoud use changes of attributes (ro, ...)
303
 
    def on_change(self, callback):
 
303
    def on_change(self, callback, field=False):
304
304
        match = re.match('^\s?(.*?)\((.*?)\)\s?$', callback)
305
305
        if not match:
306
306
            raise Exception, 'ERROR: Wrong on_change trigger: %s' % callback
307
307
        func_name = match.group(1)
308
308
        arg_names = [n.strip() for n in match.group(2).split(',') if n.strip()]
 
309
        idx = False
 
310
        if 'context' in arg_names:
 
311
            idx = arg_names.index('context')
309
312
        args = [self.expr_eval(arg) for arg in arg_names]
 
313
        if idx and field:
 
314
            args[idx].update(field.context_get(self))
310
315
        ids = self.id and [self.id] or []
311
316
        response = getattr(self.rpc, func_name)(ids, *args)
312
317
        if response: