Skip to content

Commit

Permalink
Merge pull request #245 from damdam-s/8.0-sale_payment_method-amount_…
Browse files Browse the repository at this point in the history
…zero

[FIX] do not generate payment if amount=0
  • Loading branch information
StefanRijnhart committed Mar 31, 2016
2 parents 1d28d0b + dd01dab commit d2d8c96
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sale_payment_method/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import logging
from openerp import api, models, fields, exceptions, _
import openerp.addons.decimal_precision as dp
from openerp.tools import float_is_zero

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -102,9 +103,11 @@ def automatic_payment(self, amount=None):
else:
amounts = [(date, amount)]

precision = self.env['decimal.precision'].precision_get('Account')
# reversed is cosmetic, compute returns terms in the 'wrong' order
for date, amount in reversed(amounts):
self._add_payment(journal, amount, date)
if not float_is_zero(amount, precision_digits=precision):
self._add_payment(journal, amount, date)
return True

@api.multi
Expand Down

0 comments on commit d2d8c96

Please sign in to comment.