Avoiding Infinite OnChange Loop
OnChange loop happens when 2 fields with onchange() method which return result with some decimal point residue to another field, which trigger another call and another call.
The solution is to round() method before return value, ensure there is not decimal point residue to trigger next call.
def onchange_amount(self, cr, uid, ids, field, src_amount, dst_amount, exchange_rate): res = {'value':{}} if field == 'src_amount': res['value']['src_amount'] = src_amount res['value']['dst_amount'] = round(src_amount * exchange_rate, 2) # Round to avoid infinite looping res['value']['exchange_rate'] = exchange_rate res['value']['exchange_inv'] = exchange_rate and 1.0 / exchange_rate or 0.0 elif field == 'dst_amount': res['value']['src_amount'] = round(exchange_rate and dst_amount / exchange_rate or 0.0, 2) # Round to avoid infinite looping res['value']['dst_amount'] = dst_amount res['value']['exchange_rate'] = exchange_rate res['value']['exchange_inv'] = exchange_rate and 1.0 / exchange_rate or 0.0 elif field == 'exchange_rate': res['value']['src_amount'] = src_amount res['value']['dst_amount'] = round(src_amount * exchange_rate, 2) # Round to avoid infinite looping res['value']['exchange_rate'] = exchange_rate res['value']['exchange_inv'] = exchange_rate and 1.0 / exchange_rate or 0.0 return res