~unifield-team/unifield-web/us-155

« back to all changes in this revision

Viewing changes to addons/openerp/widgets/listgrid.py

  • Committer: jf
  • Date: 2013-12-18 19:13:46 UTC
  • mfrom: (4688.1.10 web-457)
  • Revision ID: jfb@tempo-consulting.fr-20131218191346-az320og10g9bqj1r
UF-1987 [IMP] Change the logic of the "set default" (right click on field)
UTP-457 [FIX] function "set as default value" not working for users other than admin
lp:~unifield-team/unifield-web/utp-457

Show diffs side-by-side

added added

removed removed

Lines of Context:
369
369
                        values[field] = value
370
370
                    elif operator == 'in' and len(value) == 1:
371
371
                        values[field] = value[0]
372
 
                        
373
 
            #call on_change methods
374
 
            headers_index = dict([(item[0], item[1]) for item in self.headers])
375
 
            to_check = values.keys()
376
 
            for field_name in to_check:
377
 
                if not field_name in headers_index:
378
 
                    continue
379
 
                props = headers_index[field_name]
380
 
                if not "on_change" in props:
381
 
                    continue
382
 
                on_change_method = props["on_change"]
383
 
                
384
 
                match = re.match('^(.*?)\((.*)\)$', on_change_method)
385
 
                if not match:
386
 
                    raise common.error(_('Application Error'), _('Wrong on_change trigger'))
387
 
                func_name = match.group(1)
388
 
                arg_names = [n.strip() for n in match.group(2).split(',')]
389
 
                
390
 
                args = [values[arg] if arg in values else False for arg in arg_names]
391
 
                
392
 
                proxy = rpc.RPCProxy(self.model)
393
 
                response = getattr(proxy, func_name)([], *args)
394
 
                if response is False:
395
 
                    response = {}
396
 
                if 'value' not in response:
397
 
                    response['value'] = {}
398
 
                
399
 
                new_values = response["value"]
400
 
                for k, v in new_values.items():
401
 
                    if k not in values or values[k] != v:
402
 
                        values[k] = v
403
372
 
404
373
        for f in fields:
405
374
            if f in values: