2014-01-25 3 views
0

Openerp의 학습자 기본 질문이 될 수 있습니다. sqty은 = 2 그래서 2 선 내가 면적의 합계를 얻으려면 OpenERP : 루프의 값의 합

L W A 
1 2 2 
1 2 2 
    4 Sum(A) 

을 만드는 경우

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}) 

:
다음은 내 코드입니다. 아무도 날 도울 수 있을까?

+0

"면적의 합"은 무엇을 의미합니까? – user2357112

+0

내 코드를 확인하십시오. – 3156938

+3

코드가 불완전하고 불분명합니다. 그래서 나는 내 제안을 답으로 공식화 할 수 없다. 'write (...)'호출을 별도의 루프에 넣으십시오. 첫 번째 루프에서 'area_sum'변수를 'area_sum + = area'로 계산하고 새 루프에서'write (...) '호출에 사용합니다 –

답변

1

시도해 볼 수 있습니다. 도움이되기를 바랍니다.

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, 
    }) 
    Sum_area += area    
    self.pool.get('purchase.order.line').write(cr,uid,record_id, 
    'product_qty': Sum_area, 
    'product_field':product})