2014-09-29 79 views
1

我是一個完整的初學者,擁有OpenErp7。 我想展示的產品材料清單成本(product.standard_price?)和式產品成本*項目數量OpenERP 7 - 在物料清單中顯示產品成本(BoM)

我已經嘗試過

'price': fields.related('product_id','product_tmpl_id.standard_price',type='float', size=64, relation="product.product", string="Price", store=True), 
'standardprice': fields.related('product_id','standard_price',type='float', size=64, relation="product.product", string="Standard Price", store=True), 

,但它不工作。 ..我會很感激的任何暗示

在此先感謝 達維德

回答

1

你應該先繼承mrp.bom,並添加一個新的領域'price_unit': fields.float('Unit Price')

,並重新定義onchange_product_id功能如下:

def onchange_product_id(self, cr, uid, ids, product_id, name, context=None): 
    if product_id: 

     prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context) 

     return {'value': {'name': prod.name, 'product_uom': prod.uom_id.id, 'price_unit': prod.standard_price}} 

    return {} 
+0

的感謝!它正在工作! – davidetrapani 2014-11-10 18:53:22