title: Add values of integer field in one2many and store them in Openerp
body: <p>I have a custom module in i'm collecting details of the payment.I've created the fields and UI as i want.Now there is a field "amount" in one2many Field,i need sum of all "amounts" and store them in other field "total" when i save the form.
          In <strong>collectiondeatils.py</strong> , <strong>"payment_collection_details"</strong> is one2many field.Amount is a field related to <strong>"class payment.collection.details"</strong>.Now on click of save i should give the sum of amount to <strong>"Total"</strong> field which is present in <strong>collectiondetails.py</strong>. On click of save button in img1 i'm getting an error which is in img2</p>
  
  <pre><code>Error : " Uncaught Error: [_.sprintf] expecting number but found object"
   ![Img1][1]
   ![img2][2]
  
    [1]: http://i.stack.imgur.com/673h1.png
    [2]: http://i.stack.imgur.com/oiVYJ.png
  </code></pre>
  
  <p>My Code :</p>
  
  <p>Collectiondetails.py </p>
  
  <pre><code>from osv import osv
  from osv import fields
  from openerp.tools.translate import _
  from openerp.tools import html2plaintext
  
  class collection_details(osv.osv):
   _name = "collection.details"
   _description = "Collection Details"
   """docstring for collection_details"""
   def _total_amount(self, cr, uid, ids, field_name, arg, context=None):
      val1 = 0
      res = {}
      for order in self.browse(cr, uid, ids, context=context):
          res[order.id] = {
              'total' : 0,
          }
          for line in order.payment_collection_details:
              val1 += line.collection_amount
          res[order.id]['total'] = val1
      return res
  
   _columns={
      'client_name': fields.many2one('res.partner','Client Name'),
      'client_id': fields.char('Client Id',size=64),
      'mobile': fields.char('Mobile',size=15),
      'order_value':fields.integer('Order value',size=5),
      'payment_terms':fields.many2one('collection.details.paymentterms','Payment Terms'),
      'mode_of_payment':fields.selection([('cash','Cash'),('creditcard','Credit Card'),('cheque','Cheque'),('ecs','ECS'),('bajaj','Bajaj')],'Mode of Payment'),
      'payment_collection_details': fields.one2many('collection.details.payments','order_id','Collection Details'),
      'dateof_documentsRecieved': fields.date('Date od Documents recieved at HO'),
      'ecs_status':fields.selection([('recieved','Recieved'),('senttobank','Sent to Bank'),('approved','Approved by Bank'),('rejected','Rejected by Bank')],'Status of ECS Mandate'),
      'total': fields.function(_total_amount,string='Total',help="Total amount that can be collected using collection table is")
   }
  
  
   def onchange_client_name(self, cr, uid, ids, part, context=None):
      part = self.pool.get('res.partner').browse(cr, uid, part, context=context)
      val = {
          'client_id':part.client_id,
          'mobile':part.mobile,
          'order_value':part.order_value
      }
      return {'value': val}
  
  class collection_details_paymentterms(osv.osv):
      _name = "collection.details.paymentterms"
      _description = "Payment Terms"
      _order = "name"
      _columns = {
          'name' : fields.char('Payment Term',size=64),
          'schemedescription': fields.char('Scheme Description',size=64)
      }
  class collection_details_payments(osv.osv):
      _name="collection.details.payments"
      _description = "Collection Payments"
      _order = "name"
      _columns={
          'order_id': fields.many2one('collection.details', 'Order Reference',  ondelete='cascade', select=True,required=True),
          'name' : fields.char('Sl.No',size=64),
          'date' : fields.date('Date'),
          'collection_amount': fields.integer('Amount',size=5),
          'bank_name':fields.char('Bank Name',size=64),
          'cheque_no': fields.char('Cheque No'),
          'realisation_date':fields.date('Realisation Date'),
          'cheque_status': fields.selection([('realised','Realised'),('bounced','Cheque Bounced')],'Cheque Status')
      }
  </code></pre>