Odoo Help

16 Answers

Stefan Reisich

--Stefan Reisich--
Rove.design GmbH
| 7 7 8
Pfungstadt, Germany
--Stefan Reisich--

Stefan Reisich
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"/>



1 Comment
Igor MF
7/7/14, 5:59 PM

Great module, thanks!


IT Libertas

--IT Libertas--
| 4 3 7
Saint Petersburg, Russian Federation
--IT Libertas--

Visit us: https://odootools.com/

IT Libertas is a team of developers and automation experts to help you to unlock Odoo ERP system's potential. We have been communicating with end users to whom the software became a main business tool since 2012. As a result, we are proud of dozens of successful Odoo apps developed.

We are open for new ideas and challenges to create the best Odoo tools for business needs all over the world

IT Libertas
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

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 !

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

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

3/25/13, 10:09 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....

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

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!

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

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

Philipp Johne
9/11/13, 6:05 AM

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

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?

Ask a Question
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