请教如何在save的时候执行一个函数
-
有如下的一个函数,我想在保存的时候更新一下partner中的数据,请问在哪里调用这个函数才能实现保存的时候执行呢?谢谢
<br />def update_partner(self,cr,uid,ids, context=None):<br /> partner_obj = self.pool.get('res.partner')<br /> for op in self.browse(cr, uid, ids, context=context):<br /> partner = op.partner_id<br /> if partner.id:<br /> vals= {<br /> 'sale_area':op.sale_area<br /> }<br /> partner_obj.write(cr,uid,[partner.id], vals)<br /> return vals<br />
-
<br /><br />def write(self, cr, uid, ids, vals, context={}):<br /> return super(xxxx, self).write(cr, uid, ids, vals, context=context) && self.udpate_partner(cr, uid, ids, context=context)<br /><br />def update_partner(self,cr,uid,ids, context=None):<br /> partner_obj = self.pool.get('res.partner')<br /> for op in self.browse(cr, uid, ids, context=context):<br /> partner = op.partner_id<br /> if partner.id:<br /> vals= {<br /> 'sale_area':op.sale_area<br /> }<br /> partner_obj.write(cr,uid,[partner.id], vals)<br /> return vals<br /><br />