Stock wizard_partial_picking Average price computation doesn't work as expected

Bug #688493 reported by nrumprecht
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Status tracked in Trunk
5.0
Fix Released
Medium
JMA(Open ERP)
Trunk
Fix Released
Medium
OpenERP R&D Addons Team 2

Bug Description

In the wizard_partial_picking.py in line 146 the new standard_price of a product (cost_method = average) is calculated:
new_std_price = ((product.standard_price * product.qty_available) + (new_price * qty))/(product.qty_available + qty)

I've a product with a standard_price of 1500 and an available qty of 2, now i purchase 2 additional product with a unit price of 1000:

if ive one move_line with qty:2 price 1000 the calculation works fine:

((1500 * 2) + (1000 * 2)) / (2 + 2) = 1250

but if i split the the line in 2 lines each with a qty of 1 and a price of 1000 the product_qty_available will not be taken in count wich causes this problem:

((1500 * 2) + (1000 * 1)) / (2 + 1) = 1333,33
after calculating the new cost_price for the first line the new price is written in the product but the qty_available doesnt change
as the workflow action that ends the move is called later in the method.
((1333,33 * 2) + (1000 * 1)) / (2 + 1) = 1222,22
This average price is wrong, the right one would take the additional qty of the first line in count :
((1333,33 * 3) + (1000 * 1)) / (2 + 1) = 1250

Related branches

affects: openobject-server → openobject-addons
Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :

Hello,

I have tested your scenario with the latest code of trunk version. Fortunately it works fine at my end. I have attached the screen shots for your reference. So please check it and notify me if i did wrong steps for reproducing it.

Thanks.

Changed in openobject-addons:
status: New → Invalid
Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :
Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :
Revision history for this message
nrumprecht (n-rumprecht) wrote :

Hello Saz,

the screenshots does not show the new calculated standard price in product. The problem doesnt affect invoices or stock moves, the method recalculates the standard price in the product and that calculations is wrong.

Thanks

Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :

Hello,

Would you please tell me the way you are changing the standard price to 1000. Whether it is at time of purchase order creation or at the time of processing the incoming shipments i.e picking. Here i have changed the price at the time of processing the picking. And after I have checked the product's standard price and it is 1222.22 as you have specified in the bug.

Thanks.

Changed in openobject-addons:
status: Invalid → Incomplete
Revision history for this message
nrumprecht (n-rumprecht) wrote :

Hello Saz,

i've i think i tried both, but in the end i always changed the price during processing the picking.

Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :

Hello,

Steps for Reproducing this bug:

1) Make new product with costing method as an average price and give the price 1500 and update the real stock with 2 units.

2)Make a new purchase order for this product with the same price and qty=2 and then process its picking with the change in price 1000 at the time of incoming shipments.(Here process the picking without splitting the move line).

So For that product we have Qty=4 and Average Price=1250 in product's form view which is correct.

3)Now for same product please follow the steps:1,2 and this time split the move line into 2 lines with qty=1 of each.

After that open the product's form view Average Price=1222.22 which is not correct as it is the same case as previous one.

Thanks.

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Medium
status: Incomplete → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Rifakat Husen (OpenERP) (rha-openerp) wrote :

Hello,

It has been fixed in lp:~openerp-commiter/openobject-addons/dev-addons2-rha1

Revision ID: <email address hidden>
Revision no: 4476

Thanks for reporting,
rha

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
nrumprecht (n-rumprecht) wrote :

is there a way i can get this patch working for a 5.0.15 cause it think its inteded to work for 6.x

Revision history for this message
Rifakat Husen (OpenERP) (rha-openerp) wrote :

Hello,
yes this is intended to work for 6.x. You may contact <email address hidden> for stable fix.

Thanks for your support.

tags: added: maintenance
summary: - Stock wizard_partial_picking Average price computation doesnt work as
- expectet
+ Stock wizard_partial_picking Average price computation doesn't work as
+ expected
Revision history for this message
JMA(Open ERP) (jma-openerp) wrote :

Hello Nils,

It has been fixed in stable by revision: 2898 <email address hidden>

I would request you to update your code to get the changes.

Thanks.

tags: added: average-price partial-delivery
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.