Negative quant reconciliation accounting entries adjustments

Asked by AVSM

Odoo v8.0.
I have a doubt regarding the accounting entries adjustment when negative quant reconciliation takes place.
In our environment the stock valuation does not match the accounting entries. Investigating I found that this is caused by negative quant reconciliation, where the cost is updated in quants linked to negative quants when they need to be reconciled. The problem is that the accounting entries are not modified to match this new cost for the quants.

The code where this should be done is located in file "stock_account.py":

    @api.cr_uid_ids_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 = {}
        account_period = self.pool['account.period']
        super(stock_quant, self)._price_update(cr, uid, quant_ids, newprice, context=context)
        for quant in self.browse(cr, uid, quant_ids, context=context):
            move = self._get_latest_move(cr, uid, quant, context=context)
            valuation_update = newprice - quant.cost
            # this is where we post accounting entries for adjustment, if needed
            if not quant.company_id.currency_id.is_zero(valuation_update):
                # adjustment journal entry needed, cost has been updated
                period_id = (context.get('force_period') or
                                 account_period.find(cr, uid, move.date, context=context)[0])
                period = account_period.browse(cr, uid, period_id, context=context)
                # If neg quant period already closed (likely with manual valuation), skip update
                if period.state != 'done':
                    ctx = dict(context, force_valuation_amount=valuation_update)
                    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'
            #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)

The doubt is: the line "super(stock_quant, self)._price_update(cr, uid, quant_ids, newprice, context=context)" updates the cost of the quant to the new value, afterwards it calculates the difference between old and new quant cost, but as the quant cost has already been updated the result is 0 and it does not enter the code where it should create the corresponding accounting entries for the adjustment.

I would like to know if the code is correct as it is (if this is so, is it correct to have a missmatch against the stock valuation?) or if this is a bug and the update of the quant cost (super(stock_quant, self)._price_update(cr, uid, quant_ids, newprice, context=context)) should be done after the accounting entries are adjusted.

Thank you in advance.
Best regards.

Question information

Language:
English Edit question
Status:
Expired
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.