一。在主表中 #改动地方 总结算金额 求和: def _get_subtotal2(self, cr, uid, ids, field_name, arg, context=None): # 初始化 res = {} # 获取本页面单据 for order in self.browse(cr, uid, ids, context=context): subtotal2=0 # 循环遍历明细表中的数据,汇总 for line in order.line_id: # 明细表中数据,以次相加 subtotal2 += line.pay_account_line res[order.id] = subtotal2 return res 二。与明细表中关联字段
'line_id':fields.one2many('settle.account.line','contract_origin_line','Order Line', copy=True),
'total_pay':fields.function(_get_subtotal2,string=u'总支付金额',type='float',store=True,), 自动更新数据:
# 自动更新合同页面上的累计结算和累计支付 第二种方法 sigining_obj=self.pool.get('sigining.contract') sigining_obj=sigining_obj.search(cr,uid,[str('contract_origin'),'=','name'],context) sigining_obj.create(cr,uid,{'accumulated_amount':dict1['jiestotal'],'accumulated_pay':dict1['paytotal']},context=None) sigining_obj.accumulated_amount= dict1['jiestotal'] sigining_obj.accumulated_pay= dict1['paytotal']