From a5e2039aeef87c61511f220b2102cfd98568e6ac Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 15 Sep 2016 11:41:04 +0200 Subject: [PATCH] [IMP] account.invoice: include origin in payment reference Makes it easier to later reconcile payments with bank statements. For eCommerce orders the payment transaction happens before the creation of the invoice, so the invoice number is not sufficient to quickly find a match for reconciliation. --- addons/account/models/account_invoice.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index faca4362532..783dae570ac 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1017,11 +1017,15 @@ class AccountInvoice(models.Model): if payment_method not in journal_payment_methods: raise UserError(_('No appropriate payment method enabled on journal %s') % pay_journal.name) + communication = self.type in ('in_invoice', 'in_refund') and self.reference or self.number + if self.origin: + communication = '%s (%s)' % (communication, self.origin) + payment = self.env['account.payment'].create({ 'invoice_ids': [(6, 0, self.ids)], 'amount': pay_amount or self.residual, 'payment_date': date or fields.Date.context_today(self), - 'communication': self.type in ('in_invoice', 'in_refund') and self.reference or self.number, + 'communication': communication, 'partner_id': self.partner_id.id, 'partner_type': self.type in ('out_invoice', 'out_refund') and 'customer' or 'supplier', 'journal_id': pay_journal.id,