1
votes

I'm a complete beginner with OpenErp7. I would like to show the cost of products (product.standard_price?) in a Bill of Materials and the formula Product cost * item number

I've already tried

 '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),

but it's not working... I'd be grateful for any hint

Thanks in advance Davide

1

1 Answers

1
votes

You should first inherit mrp.bom and add a new field 'price_unit': fields.float('Unit Price')

and redefine the onchange_product_id function as follows :

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