Odoo Help

Stefan Reisich
On 4/5/13, 11:41 AM

Ok I finally got it! Here it is:

First you must handle a bug in OpenERP 7. You can find what to do here: https://accounts.openerp.com/forum/Help-1/question/8598

The Bug has been fixed. Just update to last revision: http://bazaar.launchpad.net/~openerp/openerp-web/7.0/revision/4027

And then this module will work:


import stock_location
import product


    'name': 'nfx Stock Location',
    'version' : '0.1',
    'author' : 'Stefan Reisich, Rove.design GmbH',
    'website' : 'http://www.rove.de/',
    'description': 'Extends Stock Location functionality',
    'category': '',
    'depends': ['stock'],
    'data': ['stock_location.xml'],
    'installable': True,


from openerp.osv import osv, fields

class product_product(osv.osv):
    _name = 'product.product'
    _inherit = 'product.product'

    def get_stock_locations(self, cr, uid, ids, field_names=None, arg=None, context=None):
        result = {}
        if not ids: return result

        context['only_with_stock'] = True

        for id in ids:
            context['product_id'] = id
            location_obj = self.pool.get('stock.location')
            result[id] = location_obj.search(cr, uid, [('usage', '=', 'internal')], context=context)

        return result

    _columns = {
        'stock_locations': fields.function(get_stock_locations, type='one2many', relation='stock.location', string='Stock by Location'),



from openerp.osv import osv

class stock_location(osv.osv):
    _name = "stock.location"
    _inherit = "stock.location"

    def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
        if context is None:
            context = {}

        res_ids = super(stock_location, self).search(cr, uid, args, offset, limit, order, context=context, count=count)
        if context.get('only_with_stock', False) is True:
            loc_obj = self.browse(cr, uid, res_ids, context=context)
            res_ids = [x.id for x in loc_obj if x.stock_real>0]

        return res_ids




            context="{'product_id': active_id, 'only_with_stock': True}"
            name="Stock by Location"

        <record id="nfx_view_normal_procurement_locations_form" model="ir.ui.view">
            <field name="name">nfx_product.normal.procurement.locations.inherit</field>
            <field name="model">product.product</field>
            <field name="inherit_id" ref="stock.view_normal_procurement_locations_form"/>
            <field name="arch" type="xml">

                <group name="status" position="before">
                    <group name="nfx_locations" string="Locations" attrs="{'invisible': [('type', '=', 'service')]}" groups="base.group_user" colspan="2">

                        <field name="stock_locations" nolabel="1" context="{'product_id': active_id}">
                            <tree string="Stock Location">
                                <field name="complete_name"/>
                                <field name="stock_real"/>
                                <field name="stock_virtual"/>




Great module, thanks!

Igor MF
on 7/7/14, 5:59 PM
IT Libertas
On 3/13/16, 5:49 PM

The module for version 8 & 9: https://www.odoo.com/forum/help-1/question/solved-knowing-the-product-stock-location-92841

On 3/25/13, 7:41 AM

Your Mock-Up would be a perfect solution for us too. Im assuming you already know about using the more button ?

While on the product page you can use the 'more' button at the top of the page (next to print) and select 'stock by location' from the dropdown....

My issue is that this gives us 2000 locations and the filter is broke. You cant click the column header 'real stock' but you can click to sort the headers 'location type' and 'location name'.. also if you use the 'Advanced Search' and select either 'real stock' or 'real stock value' is greater than 0.00 the results dont change. The view still shows all the locations including those with 0.00 stock !

yes i know about that. but we have the same problem like you. and we have many stock locations too...

Rove.design GmbH, Stefan Reisich
on 3/25/13, 8:02 AM

Hi, same issues here. And I noticed as well that you can use advanced search to filter on real stock > "0.00", but that is not working....

on 3/25/13, 10:09 AM

hey stefan, thanks a lot for your module. However, it keeps showing me the stock numbers for only one record, meaning it always stays the same when I click through different products. Can you help me with this? Thanks again!

Philipp Johne
on 9/9/13, 12:32 PM

there was a bug in openerp 7. please update to the latest revision. it was fixed here: http://bazaar.launchpad.net/~openerp/openerp-web/7.0/revision/4027

Rove.design GmbH, Stefan Reisich
on 9/10/13, 9:30 AM

Thanks! Works great now! Love the community...

Philipp Johne
on 9/11/13, 6:05 AM
On 12/10/13, 3:51 PM


I'm quite interested in this functionality for an aircraft restoration warehouse inventory. Did you ever made an addon of this? How can I make my own addon based on your code?

About This Community

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

Question tools

4 follower(s)


Asked: 3/22/13, 1:05 PM
Seen: 8063 times
Last updated: 3/13/16, 5:49 PM