From d1e01e7d5685ead0e6b70460b72ebdc2f16e5181 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Mon, 21 Jan 2013 21:25:00 +0100 Subject: [PATCH] [FIX] Make sure the invoice number is used as direct debit order line reference --- .../wizard/account_payment_order.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/account_banking/wizard/account_payment_order.py b/account_banking/wizard/account_payment_order.py index f85b556ba..f4bbfebfd 100644 --- a/account_banking/wizard/account_payment_order.py +++ b/account_banking/wizard/account_payment_order.py @@ -85,12 +85,20 @@ class payment_order_create(osv.osv_memory): state = communication2 = False communication = line.ref or '/' if line.invoice: - if line.invoice.reference_type == 'structured': - state = 'structured' - communication = line.invoice.reference + if line.invoice.type in ('in_invoice', 'in_refund'): + if line.invoice.reference_type == 'structured': + state = 'structured' + communication = line.invoice.reference + else: + state = 'normal' + communication2 = line.invoice.reference else: - state = 'normal' - communication2 = line.invoice.reference + # Make sure that the communication includes the + # customer invoice number (in the case of debit order) + communication = line.invoice.number.replace('/', '') + state = 'structured' + if communication != line.ref: + communication2 = line.ref # support debit orders when enabled if (payment.payment_order_type == 'debit' and 'amount_to_receive' in line):