Skipping quants in _create_account_move_line

Bug #1302625 reported by Daivaras
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenERP new WMS
Fix Released
Undecided
Unassigned

Bug Description

stock_account.py: "return" breaks the for loop and thus only one quant is reported in the accounting... solution: remove the word "return". Or even better would be to sum them up (total+=qty*cost) and then create accounting entry, this way we would avoid multiple valuation entries.

original function:

def _create_account_move_line(self, cr, uid, quants, move, credit_account_id, debit_account_id, journal_id, context=None):
        #group quants by cost
        quant_cost_qty = {}
        for quant in quants:
            if quant_cost_qty.get(quant.cost):
                quant_cost_qty[quant.cost] += quant.qty
            else:
                quant_cost_qty[quant.cost] = quant.qty
        move_obj = self.pool.get('account.move')
        for cost, qty in quant_cost_qty.items():
            move_lines = self._prepare_account_move_line(cr, uid, move, qty, cost, credit_account_id, debit_account_id, context=context)
            return move_obj.create(cr, uid, {'journal_id': journal_id,
                                      'line_id': move_lines,
                                      'period_id': self.pool.get('account.period').find(cr, uid, move.date, context=context)[0],
                                      'date': move.date,
                                      'ref': move.picking_id and move.picking_id.name}, context=context)

Daivaras (daivaras)
affects: openobject-addons → openerp-trunk-wms
Daivaras (daivaras)
description: updated
description: updated
description: updated
Daivaras (daivaras)
description: updated
Daivaras (daivaras)
summary: - Skipping quants in _account_move_line
+ Skipping quants in _create_account_move_line
Revision history for this message
Josse Colpaert (OpenERP) (jco-openerp) wrote :

The goal is to have a separate entry by different price. Maybe we should just remove the 'return' word. (Or maybe in one account move) Thanks for pointing out!

Changed in openerp-trunk-wms:
status: New → Confirmed
Revision history for this message
qdp (OpenERP) (qdp) wrote :

fix released in revision 9650.

Nicely spotted. Thanks for the contribution :-)
Quentin

Changed in openerp-trunk-wms:
status: Confirmed → Fix Released
Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) wrote :

Hello Guys shouldn't it be convinient to return the collection of move_ids
that were created in this method as a list of them.

I have proposed an approach.

best regards.

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.