[FIX] stock, stock_account: update of product cost price
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Tue, 24 Sep 2013 08:28:04 +0000 (10:28 +0200)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Tue, 24 Sep 2013 08:28:04 +0000 (10:28 +0200)
bzr revid: qdp-launchpad@openerp.com-20130924082804-654jv5dkywfooivu

addons/stock/stock.py
addons/stock_account/stock_account.py

index ac47e83..0ac3551 100644 (file)
@@ -375,10 +375,11 @@ class stock_quant(osv.osv):
                 remaining_to_solve_quant_ids = self.search(cr, uid, [('propagated_from_id', '=', quant_neg.id), ('id', 'not in', solved_quant_ids)], context=context)
                 if remaining_to_solve_quant_ids:
                     self.write(cr, uid, remaining_to_solve_quant_ids, {'propagated_from_id': remaining_neg_quant.id}, context=context)
-            #price update + accounting entries adjustments
-            self._price_update(cr, uid, solved_quant_ids, solving_quant.cost, context=context)
+            quant_cost = solving_quant.cost
             #delete the reconciled quants, as it is replaced by the solving quant
             self.unlink(cr, SUPERUSER_ID, [quant_neg.id, solving_quant.id], context=context)
+            #price update + accounting entries adjustments
+            self._price_update(cr, uid, solved_quant_ids, quant_cost, context=context)
             solving_quant = remaining_solving_quant
 
             #solving_quant, dummy = self._reconcile_single_negative_quant(cr, uid, to_solve_quant, solving_quant, quant_neg, qty, context=context)
index 1d5ec10..e5dc593 100644 (file)
@@ -62,6 +62,7 @@ class stock_quant(osv.osv):
     def _price_update(self, cr, uid, quant_ids, newprice, context=None):
         if context is None:
             context = {}
+        super(stock_quant, self)._price_update(cr, uid, quant_ids, newprice, context=context)
         ctx = context.copy()
         for quant in self.browse(cr, uid, quant_ids, context=context):
             move = self._get_latest_move(cr, uid, quant, context=context)
@@ -73,7 +74,6 @@ class stock_quant(osv.osv):
             #2) we just fixed a negative quant caused by an outgoing shipment
             if quant.product_id.cost_method == 'real' and quant.location_id.usage != 'internal':
                 self.pool.get('stock.move')._store_average_cost_price(cr, uid, move, context=context)
-        super(stock_quant, self)._price_update(cr, uid, quant_ids, newprice, context=context)
 
     """
     Accounting Valuation Entries