Wrong quantity available in multi company

Bug #869794 reported by Stephane SALAH
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Invalid
Undecided
Unassigned

Bug Description

computing stock.move in multi company context return wrong result.

Revision history for this message
Stephane SALAH (stephanesalah) wrote :

it seems that the resturning result in qty available don't filtering stock.move by the comany_id.

when i create a new comany, and go to product (qty by location), all location are filtering by company_id, but in a multi company location, the qty return is not filtering by stock.move.

Revision history for this message
Stephane SALAH (stephanesalah) wrote :

in stock.move there is no information about company_id.

so we can not filtering stock.move by company_id. only on stock.picking.

see product.py : module stock line 254.

se the cr.execute on stock_move.

thaks for all

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello,

I have checked your bug report. Yes, you are right the quantity calculated based on stock move.
You can see the quantity on location by using "Stock By Location" and which is calculated based on stock move.

But I doesn't agree with you I have seen the company_id field in stock.move object please see the line no 1560 on stock.py.

For more information I have attached a screen-shot where you can see the company field in stock moves.

So would you please check this and notify us where you faced the problem.

Thanks and waiting for your reply!

Revision history for this message
Amit Parik (amit-parik) wrote :
Changed in openobject-addons:
status: New → Incomplete
tags: added: main
tags: added: maintenance
removed: main
Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
Changed in openobject-addons:
assignee: OpenERP Publisher's Warranty Team (openerp-opw) → nobody
tags: removed: maintenance
Revision history for this message
Stephane SALAH (stephanesalah) wrote :

yes the company_id is in the stock.move object.

but when computing the sty_available, the fields company_id is not use.

si when you affect a location to a comany you can filtering the qty_available.

but if you have a multi comany location, the qty is not filtering by company.

Revision history for this message
Stephane SALAH (stephanesalah) wrote :

the qty_available is computing by executing directly an sql query.

so the multi company filtering is not available

see the code bellow

        if 'in' in what:
            # all moves from a location out of the set to a location in the set
            cr.execute(
                'select sum(product_qty), product_id, product_uom '\
                'from stock_move '\
                'where location_id NOT IN %s '\
                'and location_dest_id IN %s '\
                'and product_id IN %s '\
                '' + (prodlot_id and ('and prodlot_id = ' + str(prodlot_id)) or '') + ' '\
                'and state IN %s ' + (date_str and 'and '+date_str+' ' or '') +' '\
                'group by product_id,product_uom',tuple(where))
            results = cr.fetchall()
        if 'out' in what:
            # all moves from a location in the set to a location out of the set
            cr.execute(
                'select sum(product_qty), product_id, product_uom '\
                'from stock_move '\
                'where location_id IN %s '\
                'and location_dest_id NOT IN %s '\
                'and product_id IN %s '\
                '' + (prodlot_id and ('and prodlot_id = ' + str(prodlot_id)) or '') + ' '\
                'and state in %s ' + (date_str and 'and '+date_str+' ' or '') + ' '\
                'group by product_id,product_uom',tuple(where))
            results2 = cr.fetchall()

Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :
Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello Stephane,

I have checked your issue in Trunk as well as stable.
It display right quantity Stock By Location calculated based on stock move for multi company environment.

I have attached a video for your more reference so would you please check it and notify us.

Thanks & waiting you replay !!

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Stephane,

As per the comment#7 's video all are working fine.

So Would you please try again with the latest code and currently I am closing this issue If you still face the problem then you can reopen this with more information.

Thank you!

Changed in openobject-addons:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.