2012-08-03 72 views
-1

我想問。當我做一個數據庫查詢AttributeError:'bool'對象沒有屬性'id'

def onchange_dept_from(self, cr, uid, ids, partner): 
    print partner 
    if partner != False: 
     # note 
     cr.execute('select z.name, z.id from res_partner x, account_account z where x.property_deposit_receivable = z.id AND x.id=%s',(partner,)), 
     temp = cr.fetchone() 
     name = temp and temp[0] or None 

     cr.execute('select z.name, z.id from res_partner x, account_account z where x.property_deposit_payable = z.id AND x.id=%s',(partner,)), 
     ads = cr.fetchone() 
     name2 = ads and ads[0] or None 

     val = { 
      'dept_from':name, 
      'dept_to':name2, 
     } 
     return {'value':val } 

的「ID」的可能性,我得到的錯誤衝突從我用來進入account.move

def get_move_line(self, cr, uid, deposit, type, context=None): 
    return { 
      'type': type, 
      'name': deposit.name or 'add', 
      'debit': type == 'dest' and deposit.amount or 0.0, 
      'credit': type == 'src' and deposit.amount or 0.0, 
      'account_id': type == 'src' and deposit.dept_from.id or deposit.dept_to.id, 
      'date': deposit.date, 
      'deposit_id': deposit.id 
    } 

我想大概函數來了因爲當時我不得不查詢字符串,而函數get_move。我正在尋找一個整數。我該怎麼辦?我沒有想法。請幫我

+1

發佈您的追蹤以顯示錯誤的位置。 – 2012-08-03 08:58:14

回答

0

我已經解決了這個問題。我只是添加查詢搜索ID。

def get_move_line(self, cr, uid, deposit, type, context=None): 
    cr.execute('select b.property_deposit_payable, b.property_deposit_receivable from deposit_travel a, res_partner b where a.partner = b.id and b.id = %s',(deposit.partner.id,)), 
    tmp = cr.fetchone() 
    dep_pay = tmp and tmp[0] or None 
    dep_rec = tmp and tmp[1] or None 
    return { 
      'type': type, 
      'name': deposit.name or 'add', 
      'debit': type == 'dest' and deposit.amount or 0.0, 
      'credit': type == 'src' and deposit.amount or 0.0, 
      'account_id': type == 'src' and dep_pay or dep_rec, 
      'date': deposit.date, 
      'deposit_id': deposit.id