这是我的方法:
def onchange_book_limit(self, cr, uid, ids, partner_id, context=None)
if partner_id:
cr.execute(""" select count(*) from rmkbook_issue where retflag!= 1 and partner_id = %s """ %(partner_id))
cnt=cr.fetchone()
cnt1=integer(cnt[0])
if(cnt1 > 3):
cr.execute("""insert into testwizard(orderid1) values(%s)""" %(cnt1))
raise osv.except_osv(_('Error!'), _('Sorry...You have exceeds the limit to take a book....!'))
return partner_id