changeset 0065dd10669c in modules/account_payment:default
details: 
https://hg.tryton.org/modules/account_payment?cmd=changeset;node=0065dd10669c
description:
        Add context option to disable payment from amount to pay

        issue8068
        review287171003
diffstat:

 account.py |  32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diffs (45 lines):

diff -r 7f9e78e5ec7a -r 0065dd10669c account.py
--- a/account.py        Sun Mar 31 00:15:09 2019 +0100
+++ b/account.py        Thu Apr 04 19:07:34 2019 +0200
@@ -416,24 +416,26 @@
         pool = Pool()
         Currency = pool.get('currency.currency')
         Date = pool.get('ir.date')
+        context = Transaction().context
 
         today = Date.today()
 
         amounts = super(Invoice, cls).get_amount_to_pay(invoices, name)
 
-        for invoice in invoices:
-            for line in invoice.lines_to_pay:
-                if line.reconciliation:
-                    continue
-                if (name == 'amount_to_pay_today'
-                        and line.maturity_date > today):
-                    continue
-                payment_amount = Decimal(0)
-                for payment in line.payments:
-                    if payment.state != 'failed':
-                        with Transaction().set_context(date=payment.date):
-                            payment_amount += Currency.compute(
-                                payment.currency, payment.amount,
-                                invoice.currency)
-                amounts[invoice.id] -= payment_amount
+        if context.get('with_payment', True):
+            for invoice in invoices:
+                for line in invoice.lines_to_pay:
+                    if line.reconciliation:
+                        continue
+                    if (name == 'amount_to_pay_today'
+                            and line.maturity_date > today):
+                        continue
+                    payment_amount = Decimal(0)
+                    for payment in line.payments:
+                        if payment.state != 'failed':
+                            with Transaction().set_context(date=payment.date):
+                                payment_amount += Currency.compute(
+                                    payment.currency, payment.amount,
+                                    invoice.currency)
+                    amounts[invoice.id] -= payment_amount
         return amounts

Reply via email to