[IMP] Account : Reference allocation to move/move.line improved

bzr revid: jvo@tinyerp.com-20091210061540-bknsoac2uggfyquy
This commit is contained in:
VRA(OpenERP) 2009-12-10 11:45:40 +05:30 committed by Jay (Open ERP)
parent 9419635c74
commit d5648a112c
1 changed files with 8 additions and 4 deletions

View File

@ -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 = []