[FIX] stock_landed_costs: avoid useless multiple writes
Initialise quant_dict inside for loop as doing outside loops renders to be a quadratic write of quant object due to the fact that previous quants are kept each time a new valuation line is read. In case of posting a Landed Cost record with a huge amount of cost_lines and huge amount of stock_move having several quants would result in a extra overhead. Closes #9005
This commit is contained in:
parent
c862b2f37a
commit
81418ec14e
|
@ -202,13 +202,13 @@ class stock_landed_cost(osv.osv):
|
|||
if not cost.valuation_adjustment_lines or not self._check_sum(cr, uid, cost, context=context):
|
||||
raise osv.except_osv(_('Error!'), _('You cannot validate a landed cost which has no valid valuation lines.'))
|
||||
move_id = self._create_account_move(cr, uid, cost, context=context)
|
||||
quant_dict = {}
|
||||
for line in cost.valuation_adjustment_lines:
|
||||
if not line.move_id:
|
||||
continue
|
||||
per_unit = line.final_cost / line.quantity
|
||||
diff = per_unit - line.former_cost_per_unit
|
||||
quants = [quant for quant in line.move_id.quant_ids]
|
||||
quant_dict = {}
|
||||
for quant in quants:
|
||||
if quant.id not in quant_dict:
|
||||
quant_dict[quant.id] = quant.cost + diff
|
||||
|
|
Loading…
Reference in New Issue