[MERGE] payment of invoice with amount_total = 0 is a valid operation, and is now...
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Fri, 21 Dec 2012 16:32:52 +0000 (17:32 +0100)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Fri, 21 Dec 2012 16:32:52 +0000 (17:32 +0100)
bzr revid: qdp-launchpad@openerp.com-20121221163252-q0hi14lrdcnnz5wm

1  2 
addons/account_voucher/account_voucher.py

@@@ -1082,9 -1083,11 +1083,11 @@@ class account_voucher(osv.osv)
          voucher_brw = self.pool.get('account.voucher').browse(cr, uid, voucher_id, context)
          ctx = context.copy()
          ctx.update({'date': voucher_brw.date})
+         prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
          for line in voucher_brw.line_ids:
              #create one move line per voucher line where amount is not 0.0
-             if not line.amount:
 -            #The second part of the condition handle cases were payment/receipt has an amount of 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)):
                  continue
              # convert the amount set on the voucher line into the currency of the voucher's company
              amount = self._convert_amount(cr, uid, line.untax_amount or line.amount, voucher_brw.id, context=ctx)