[FIX] stock: fixing product cost price updates in case of negative quants
bzr revid: qdp-launchpad@openerp.com-20130924124906-gdmnzv85hnjrtqgb
This commit is contained in:
parent
856b4a284e
commit
434838b9a5
|
@ -366,8 +366,6 @@ class stock_quant(osv.osv):
|
|||
solved_quant_ids.append(to_solve_quant.id)
|
||||
self._quant_split(cr, uid, to_solve_quant, min(solving_qty, to_solve_quant.qty), context=context)
|
||||
solving_qty -= min(solving_qty, to_solve_quant.qty)
|
||||
#merge history (and cost?)
|
||||
self._quants_merge(cr, uid, solved_quant_ids, solving_quant, context=context)
|
||||
remaining_solving_quant = self._quant_split(cr, uid, solving_quant, qty, context=context)
|
||||
remaining_neg_quant = self._quant_split(cr, uid, quant_neg, -qty, context=context)
|
||||
#if the reconciliation was not complete, we need to link together the remaining parts
|
||||
|
@ -375,11 +373,13 @@ 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)
|
||||
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)
|
||||
#delete the reconciled quants, as it is replaced by the solved quants
|
||||
self.unlink(cr, SUPERUSER_ID, [quant_neg.id], context=context)
|
||||
#price update + accounting entries adjustments
|
||||
self._price_update(cr, uid, solved_quant_ids, quant_cost, context=context)
|
||||
self._price_update(cr, uid, solved_quant_ids, solving_quant.cost, context=context)
|
||||
#merge history (and cost?)
|
||||
self._quants_merge(cr, uid, solved_quant_ids, solving_quant, context=context)
|
||||
self.unlink(cr, SUPERUSER_ID, [solving_quant.id], 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)
|
||||
|
|
|
@ -60,14 +60,16 @@ class stock_quant(osv.osv):
|
|||
return super(stock_quant, self)._get_inventory_value(cr, uid, line, prodbrow, context=context)
|
||||
|
||||
def _price_update(self, cr, uid, quant_ids, newprice, context=None):
|
||||
''' This function is called at the end of negative quant reconciliation and does the accounting entries adjustemnts and the update of the product cost price if needed
|
||||
'''
|
||||
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)
|
||||
ctx['force_valuation_amount'] = newprice - quant.cost
|
||||
# this is where we post accounting entries for adjustment
|
||||
ctx['force_valuation_amount'] = newprice - quant.cost
|
||||
self._account_entry_move(cr, uid, quant, move, context=ctx)
|
||||
#update the standard price of the product, only if we would have done it if we'd have had enough stock at first, which means
|
||||
#1) the product cost's method is 'real'
|
||||
|
|
Loading…
Reference in New Issue