Merge lp:~openerp-dev/openobject-addons/7.0-opw-597108-dhs into lp:openobject-addons/7.0

Proposed by Dhruti Shastri(OpenERP)
Status: Approved
Approved by: Vinay Rana (OpenERP)
Approved revision: 9527
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-597108-dhs
Merge into: lp:openobject-addons/7.0
Diff against target: 44 lines (+35/-0)
1 file modified
purchase/stock.py (+35/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-597108-dhs
Reviewer Review Type Date Requested Status
Vinay Rana (OpenERP) (community) Approve
Naresh(OpenERP) Pending
Review via email: mp+191560@code.launchpad.net

Description of the change

Hello Sir,

[FIX]purchase: Button "Process Entirely" doesn't update average price

Steps to reproduce this issue,
1. Create product having (average) cost Price = 100
2. Now Create purchase order with this product but with cost price 200.
3. Go to Incoming shipment and receive product with option "Process Entirely"

Expected result:

* Product cost price should be updated with 200.

To post a comment you must log in.
Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) wrote :

The Propose Fix will fixes the average costing calculation for stock move entire button.

review: Approve

Unmerged revisions

9527. By Dhruti Shastri(OpenERP)

[purcahse]:In Warehouse button Process Entirely is not updating average cost(case:597108)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'purchase/stock.py'
2--- purchase/stock.py 2012-12-06 14:56:32 +0000
3+++ purchase/stock.py 2013-10-17 06:42:46 +0000
4@@ -28,6 +28,41 @@
5 'Purchase Order Line', ondelete='set null', select=True,
6 readonly=True),
7 }
8+
9+ def action_done(self, cr, uid, ids, context=None):
10+ """ Inherited action of stock to compute cost price based on Purchase order
11+ line.
12+ @return:
13+ """
14+ # This fucntion doesn't calculate Cost Price for Average Method
15+ for move in self.browse(cr, uid, ids, context=context):
16+ if (move.picking_id.type == 'in') and (move.product_id.cost_method == 'average'):
17+ product_obj = self.pool.get('product.product')
18+ currency_obj = self.pool.get('res.currency')
19+ uom_obj = self.pool.get('product.uom')
20+ product = product_obj.browse(cr, uid, move.product_id.id)
21+ move_currency_id = move.company_id.currency_id.id
22+ context['currency_id'] = move_currency_id
23+ qty = uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, product.uom_id.id)
24+ if move.product_qty > 0:
25+ amount_unit = product.price_get('standard_price', context=context)[product.id]
26+ price_unit = amount_unit
27+ if move.purchase_line_id :
28+ purchase_obj = self.pool.get('purchase.order.line').browse(cr, uid, move.purchase_line_id.id)
29+ price_unit = purchase_obj.price_unit
30+ if qty > 0:
31+ new_price = currency_obj.compute(cr, uid, move.price_currency_id.id,
32+ move_currency_id, price_unit)
33+ new_price = uom_obj._compute_price(cr, uid, move.product_uom.id, new_price,
34+ product.uom_id.id)
35+ if product.qty_available <= 0:
36+ new_std_price = new_price
37+ else :
38+ new_std_price = ((amount_unit * product.qty_available)\
39+ + (price_unit * move.product_qty))/(product.qty_available + move.product_qty)
40+ product_obj.write(cr, uid, [product.id],{'standard_price': new_std_price})
41+
42+ return super(stock_move, self).action_done(cr, uid, ids, context=None)
43
44 stock_move()
45