[FIX] account_voucher: evaluate move line account with correct precision
authorMartin Trigaux <mat@openerp.com>
Fri, 2 Aug 2013 12:03:11 +0000 (14:03 +0200)
committerMartin Trigaux <mat@openerp.com>
Fri, 2 Aug 2013 12:03:11 +0000 (14:03 +0200)
This bug may have generated incorrect account_voucher_line when validating a voucher with amount less than 1. This patch will avoid reproducing the problem on new lines but not fix already existing vouchers. To do so apply the following steps:

1. apply this patch
2. do a manual reconciliation of the account.move.lines with amount less than 1 (use the manual reconciliation menu to see every line, included 0-0 lines)
3. execute the following SQL query

DELETE FROM account_voucher_line WHERE id IN (SELECT l.id FROM account_voucher_line AS l JOIN account_voucher AS v ON (v.id = l.voucher_id) JOIN account_move_line AS ml ON (l.move_line_id = ml.id) WHERE l.amount = 0 AND v.state = 'draft' AND ml.debit = ml.credit AND ml.credit = 0);

that will remove account voucher lines from draft vouchers linked to an empty move lines

bzr revid: mat@openerp.com-20130802120311-oh64d47t8x6t1wf9

addons/account_voucher/account_voucher.py

index d9a3fef..4f383a1 100644 (file)
@@ -1198,7 +1198,7 @@ class account_voucher(osv.osv):
         for line in voucher.line_ids:
             #create one move line per voucher line where amount is not 0.0
             # AND (second part of the clause) only if the original move line was not having debit = credit = 0 (which is a legal value)
-            if not line.amount and not (line.move_line_id and not float_compare(line.move_line_id.debit, line.move_line_id.credit, precision_rounding=prec) and not float_compare(line.move_line_id.debit, 0.0, precision_rounding=prec)):
+            if not line.amount and not (line.move_line_id and not float_compare(line.move_line_id.debit, line.move_line_id.credit, precision_digits=prec) and not float_compare(line.move_line_id.debit, 0.0, precision_digits=prec)):
                 continue
             # convert the amount set on the voucher line into the currency of the voucher's company
             # this calls res_curreny.compute() with the right context, so that it will take either the rate on the voucher if it is relevant or will use the default behaviour