OpenERP:循环中的值之和

2024-10-06 07:03:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我是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条线

^{pr2}$

我要求面积之和。有人能帮我吗?在


Tags: selfiduidgetarea学习者productwidth
1条回答
网友
1楼 · 发布于 2024-10-06 07:03:00

你可以试试这个。希望这会有帮助

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

相关问题 更多 >