Odoo Help


Error on Method Calculating Quantity Available less Outgoing Quantity in Function Field.

Michael Thomas
on 1/12/15, 7:39 AM 928 views

I am trying to implement the following code in order to create a function field in my product model that will give me the qty_available result less the outgoing_qty result. I am currently getting a: 'NoneType' object has no attribute 'qty_available' error. I am assuming that is because I am trying to get the value of qty_available in the incorrect way. What adjustments should I make to my code?

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 product in self.browse(cr, uid, ids, context):
            result[product.id] = product.qty_available - product.outgoing_qty
        return result

    _columns = {
        'testing_time': fields.integer('Test Field', help='Just a field for testing'),
        'real_inventory_count': fields.function(real_inventory_count, type='float', string='Real Inventory Count'),


Leonardo Donelli

--Leonardo Donelli--
| 5 4 8
Roma, Italy
--Leonardo Donelli--

Physics student and part-time developer.

Leonardo Donelli
On 1/12/15, 11:13 AM

There already is a module that does that: stock_available_immediately

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/12/15, 7:39 AM
Seen: 928 times
Last updated: 3/16/15, 8:10 AM