title: Type error: argument 2 to map() must support iteration
body: <p>I am getting the error:
  Type error: argument 2 to map() must support iteration
  when trying to save. The view is rendered correctly and all the calculations are the way I want. But when I click on save, I get the mentioned error. I believe the problem is with the type of object I am passing for write. Can someone please suggest what change I should make to the below code to fix the issue?</p>
  
  <p>Below is my code:</p>
  
  <pre><code>class export_rebate(osv.osv):
      _name = 'export.rebate'
  
      def _cal_difference(self, cr, uid, ids, field_names, arg=None, context=None):
          res = {}
          for item in self.browse(cr, uid, ids, context=context):
              res[item.id] = item.rebate_amount or 0.0 - item.amount_received or 0.0
          return res
  
      def _get_quantity (self, cr, uid, ids, field_names, arg=None, context=None):
          res = {}
          for line in self.browse(cr,uid,ids,context=context):
              qty = 0.0
              invoice = line.invoice_id
              if invoice and invoice.invoice_line:
                  for invline in invoice.invoice_line: 
                      qty += invline.quantity
                  res[line.id] = qty
          return res       
  
      def onchange_invoice_id(self, cr, uid, ids, invoice_id):
          print 'on_change called'
          res = {}
          if invoice_id:
              inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id)
              res['date_invoice'] = inv.date_invoice or False
              res['form_e_num'] = inv.form_e_num or False
              res['form_e_date'] = inv.form_e_date or False        
              res['invoice_line'] = [x.id for x in inv.invoice_line or []]
          return {'value': res}
  
      _columns = {
              'invoice_id': fields.many2one('account.invoice', 'Invoice No.'),
              'type': fields.char('Type', size=64, readonly=True, select=True),
              'state': fields.char('Status', select=True, readonly=True),
              'date_invoice': fields.related('invoice_id', 'date_invoice', string='Invoice Date', relation='account.invoice', type='date', readonly=True),                
              'form_e_num': fields.related('invoice_id', 'form_e_num', string='Form E No.', relation='account.invoice', type='char', readonly=True),
              'form_e_date': fields.related('invoice_id', 'form_e_date', string='Form E Date', relation='account.invoice', type='date', readonly=True),
              'invoice_line': fields.related('invoice_id', 'id', relation='account.invoice.line', type='one2many', readonly=True),
              'quantity': fields.function(_get_quantity, type='float', digits=(16,2), string='Quantity', store=True, readonly=True),
  
              'rebate_file_num': fields.char('Rebate File No.', size=64, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
              'claim_file_date': fields.date('Claim File Date', select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
              'rebate_amount': fields.float('Rebate Amount', digits=(16,2), states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
              'rebate_rate': fields.float('Rebate Rate', digits=(16,2), states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
              'gd_num': fields.char('G.D. No.', size=64, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
              'gd_date': fields.date('G.D. Date', select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
              'prc_date': fields.date('PRC Date', select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
              'claim_sbmt_date': fields.date('Claim Submission Date', select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
  
              'cheque_num': fields.char('Cheque No.', size=64, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
              'cheque_date': fields.date('Cheque Date', select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
              'amount_received': fields.float('Amount Received', digits=(16,2), states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),                                
              'Net_amt_rcvd': fields.float('net Amount Received', digits=(16,2), states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
              'difference': fields.function(_cal_difference, type='float', digits=(16,2), string='Difference', store=True, readonly=True)                
              }
      _default = {
              'quantity': 0.00
              }
  
  export_rebate() 
  </code></pre>