diff --git a/addons/account/invoice.py b/addons/account/invoice.py index e9484ff312d..77a96b3140e 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -899,14 +899,18 @@ class account_invoice(osv.osv): else: amount_currency = False currency_id = False - + + if invoice.type in ('in_invoice', 'in_refund'): + ref = invoice.reference + else: + ref = self._convert_ref(cr, uid, invoice.number) # Pay attention to the sign for both debit/credit AND amount_currency l1 = { 'debit': direction * pay_amount>0 and direction * pay_amount, 'credit': direction * pay_amount<0 and - direction * pay_amount, 'account_id': src_account_id, 'partner_id': invoice.partner_id.id, - 'ref':invoice.number, + 'ref':ref, 'date': date, 'currency_id':currency_id, 'amount_currency':amount_currency and direction * amount_currency or 0.0, @@ -916,7 +920,7 @@ class account_invoice(osv.osv): 'credit': direction * pay_amount>0 and direction * pay_amount, 'account_id': pay_account_id, 'partner_id': invoice.partner_id.id, - 'ref':invoice.number, + 'ref':ref, 'date': date, 'currency_id':currency_id, 'amount_currency':amount_currency and - direction * amount_currency or 0.0, @@ -928,7 +932,7 @@ class account_invoice(osv.osv): l2['name'] = name lines = [(0, 0, l1), (0, 0, l2)] - move = {'ref': invoice.number, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} + move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} move_id = self.pool.get('account.move').create(cr, uid, move, context=context) line_ids = []