2017-02-23 82 views
-5

我想寫一個程序來計算店裏的襯衫總數。這裏'襯衫'是包含一些int值的字段。我正在計算襯衫的所有價值,但它發佈錯誤請檢查並確認繼續。typerror int對象不是迭代

shirt = fields.Integer(string='Custom Shirts (Pcs)') 

@api.onchange('shirt') 
def shirts_total_count(self): 
    add_shirts=0 
    if self.shirt: 
     for temp in self.shirt: 
      add_shirts=add_shirts+temp.shirt 
+1

請發佈整個堆棧跟蹤。 – DyZ

回答

0

您不能迭代整數字段,因爲它只包含一個值。你只能遍歷odoo的關係域,如One2manymany2many