[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.
This commit is contained in:
Olivier Dony
2016-09-16 11:31:37 +02:00
parent 10cde43fd4
commit a5e2039aee
+5 -1
View File
@@ -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,