0
我是Openerp的學習者可能會是基本問題。
下面是我的代碼:OpenERP:循環中的值總和
def add_slab_info(self, cr, uid, ids, context={}):
sqty=2
for qty in range(0,sqty):
area = (length) * (width)
Self.pool.get(object).create(cr, uid, {'product_id':value.product_id.id,
'sno':no,'length':length,'width':width,'price':price,
'area':area,
})
self.pool.get('purchase.order.line').write(cr,uid,record_id,
'product_qty': sum(area),
'product_field':product})
如果sqty = 2那麼它會創建2號線
L W A
1 2 2
1 2 2
4 Sum(A)
我想要得到面積的總和。任何人都可以幫我嗎?
你是什麼意思的「面積總和」? – user2357112
請檢查我的代碼是否已更新 – 3156938
您的代碼看起來非常不完整,並且對我不清楚。這就是爲什麼我不能將我的建議作爲答案。你爲什麼不嘗試把'write(...)'調用放在一個單獨的循環中。在第一個循環中,您將計算您的'area_sum'變量爲'area_sum + = area',並在新循環中將您的'write(...)'調用中使用它 –