Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Module/Function that shows/returns stock locations in products

Subscribe

Get notified when there's activity on this post

This question has been flagged
stockproductstock_location
16 Replies
17892 Views
Avatar
Stefan Reisich

I want develop a module that shows the stock locations with quantity in the product form like in the image. Of course only the locations with quantity > 0.

Maybe Somebody knows a function that gets the location ids? Or maybe exists such a module already. Can somebody give me some hints or code?

image description

14
Avatar
Discard
john

looks good, we would use this.......

Stefan Reisich
Author

so vote for me to make this question more important... I need help with this...

john

i know... i cant see the option though !

Stefan Reisich
Author

just click on the arrow up, left of the question title :-)

Stefan Reisich
Author

i have some updates, but i'm stuck on this problem: http://help.openerp.com/question/8598/how-can-i-pass-context-to-a-one2many-field/ maybe someone can help me on this...

Stefan Reisich
Author

context bug is finally fixed: http://bazaar.launchpad.net/~openerp/openerp-web/7.0/revision/4027

Avatar
Stefan Reisich
Author Best Answer

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:

__init__.py:

import stock_location
import product

__openerp__.py:

{
    '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,
}

product.py:

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'),
    }

product_product()

stock_location.py:

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


stock_location()

stock_location.xml:

<openerp>
    <data>

        <act_window
            context="{'product_id': active_id, 'only_with_stock': True}"
            id="act_stock_product_location_open"
            name="Stock by Location"
            res_model="stock.location"
            src_model="product.product"/>


        <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"/>
                            </tree>
                        </field>

                    </group>
                </group>

            </field>
        </record>

    </data>
</openerp>
5
Avatar
Discard
Igor MF

Great module, thanks!

Avatar
Denis Baranov
Best Answer

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

0
Avatar
Discard
Avatar
john
Best Answer

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 !

0
Avatar
Discard
Stefan Reisich
Author

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

patrick

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

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!

Stefan Reisich
Author

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

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

Avatar
geert
Best Answer

Hi,

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?

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Product quantity is still appearing the same in the Log after manually editing it
stock product stock_location stock_move
Avatar
Avatar
1
Dec 20
3353
Where is the stock in product profile? Solved
stock product stock_location odoov11
Avatar
Avatar
2
Sep 20
3658
Option "Stock Product" is missing in "Product Type" Solved
stock product
Avatar
Avatar
Avatar
3
Aug 24
2720
Error on Product Creation. State in Archived.
stock product
Avatar
0
Aug 21
2739
How can I see the stock location of an product? Solved
product stock_location
Avatar
Avatar
Avatar
Avatar
Avatar
18
Jun 21
29887
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now