This question has been flagged
1 Reply
2953 Views

On the stock.inventory.line model I would like to add a related field in order to show the quantity available on a row. However, I'm getting an error message after adding this to the stock.py (I will move to seperate module once it works). 

I am trying to use the following:

class stock_inventory_line(osv.osv):
    _name = "stock.inventory.line"
    _description = "Inventory Line"
    _rec_name = "inventory_id"
   _columns = {
       'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
       'qty_available': fields.related('product_id', 'qty_available', string='Current')

I am getting a http handler error when I use the code. 

Avatar
Discard
Author Best Answer

In python, commas are very important!!

       'qty_available': fields.related('product_id', 'qty_available', string='Current'),

I pasted my code without adding a comma at the end of the field. This resolved my problem. 

Avatar
Discard

that's good practice but doesn't make sense here if this field was defined at last in _columns if not it should raise an error.