0
votes

I am working on a custom module for OpenERP 7 (Odoo) and I am struggling to get my function to run. My goal is to create a field called real inventory count, which pulls from the preexisting qty_available and outgoing_qty columns and gives me the difference. I have tried quite a few attempts at this problem, and this code is the latest:

from openerp.osv import fields, osv

class real_inventory_counter(osv.osv): _inherit = "product.product"

def real_inventory_count(self, cr, uid, arg, ids, field_name, context=None):
    result = []
    for item in self.browse(cr, uid, ids, context=context):
        result[item.id] = item.qty_available - item.outgoing_qty
    return result

_columns = {
  'real_inventory_count': fields.function(real_inventory_count, type='float', string='Real Inventory Count'),
}

Regardless of what I do, I seem to get the following error:

AttributeError: 'NoneType' object has no attribute 'qty_available'

I believe what I want is to return when this method is called is an array of the values. It seems that self.browse is not returning the right type, but I'm not sure. What is causing this error?

1

1 Answers

0
votes

Your function definition is wrong in terms of order of arguments. It should be as follow:

def real_inventory_count(self, cr, uid, ids, arg, field_name, context=None):

Change it like this and it will work.