Odoo Help

Welcome!

This community 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.

0

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

By
Michael Thomas
on 1/12/15, 7:39 AM 573 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'),
    } 

0

Leonardo Donelli

--Leonardo Donelli--
1040
| 5 4 8
Cave, 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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