Bugfix reconciliation multi-currencies
bzr revid: fp@tinyerp.com-a76b09c553a9b9a30c4d7aad6032ee0fdd62ff79
This commit is contained in:
parent
ab9cd583f8
commit
f70d110510
|
@ -454,7 +454,8 @@ class account_move_line(osv.osv):
|
|||
id_set = ','.join(map(str, ids))
|
||||
lines = self.browse(cr, uid, ids, context=context)
|
||||
unrec_lines = filter(lambda x: not x['reconcile_id'], lines)
|
||||
credit = debit = 0
|
||||
credit = debit = 0.0
|
||||
currency = 0.0
|
||||
account_id = False
|
||||
partner_id = False
|
||||
for line in unrec_lines:
|
||||
|
@ -463,6 +464,7 @@ class account_move_line(osv.osv):
|
|||
'Entry "%s" is not valid !' % line.name)
|
||||
credit += line['credit']
|
||||
debit += line['debit']
|
||||
currency += line['amount_currency'] or 0.0
|
||||
account_id = line['account_id']['id']
|
||||
partner_id = (line['partner_id'] and line['partner_id']['id']) or False
|
||||
writeoff = debit - credit
|
||||
|
@ -482,7 +484,8 @@ class account_move_line(osv.osv):
|
|||
if r[0][1] != None:
|
||||
raise osv.except_osv('Error', 'Some entries are already reconciled !')
|
||||
|
||||
if not self.pool.get('res.currency').is_zero(cr, uid, account.company_id.currency_id, writeoff):
|
||||
if (not self.pool.get('res.currency').is_zero(cr, uid, account.company_id.currency_id, writeoff)) or \
|
||||
(account.currency_id and (not self.pool.get('res.currency').is_zero(cr, uid, account.currency_id, currency))):
|
||||
if not writeoff_acc_id:
|
||||
raise osv.except_osv('Warning', 'You have to provide an account for the write off entry !')
|
||||
if writeoff > 0:
|
||||
|
@ -497,8 +500,24 @@ class account_move_line(osv.osv):
|
|||
self_debit = -writeoff
|
||||
|
||||
writeoff_lines = [
|
||||
(0, 0, {'name':'Write-Off', 'debit':self_debit, 'credit':self_credit, 'account_id':account_id, 'date':date, 'partner_id':partner_id}),
|
||||
(0, 0, {'name':'Write-Off', 'debit':debit, 'credit':credit, 'account_id':writeoff_acc_id, 'date':date, 'partner_id':partner_id})
|
||||
(0, 0, {
|
||||
'name':'Write-Off',
|
||||
'debit':self_debit,
|
||||
'credit':self_credit,
|
||||
'account_id':account_id,
|
||||
'date':date,
|
||||
'partner_id':partner_id,
|
||||
'currency_id': account.currency_id.id or False,
|
||||
'amount_currency': account.currency_id.id and -currency or 0.0
|
||||
}),
|
||||
(0, 0, {
|
||||
'name':'Write-Off',
|
||||
'debit':debit,
|
||||
'credit':credit,
|
||||
'account_id':writeoff_acc_id,
|
||||
'date':date,
|
||||
'partner_id':partner_id
|
||||
})
|
||||
]
|
||||
|
||||
name = 'Write-Off'
|
||||
|
@ -715,7 +734,7 @@ class account_move_line(osv.osv):
|
|||
ctx = {}
|
||||
if 'date' in vals:
|
||||
ctx['date'] = vals['date']
|
||||
vals['amount_currency'] = cur_obj.compute(cr, uid, account.company_id.currency_id.id, account.currency_id.id, vals.get('debit', 0.0)+vals.get('credit', 0.0), context=ctx)
|
||||
vals['amount_currency'] = cur_obj.compute(cr, uid, account.company_id.currency_id.id, account.currency_id.id, vals.get('debit', 0.0)-vals.get('credit', 0.0), context=ctx)
|
||||
if not ok:
|
||||
raise osv.except_osv('Bad account !', 'You can not use this general account in this journal !')
|
||||
result = super(osv.osv, self).create(cr, uid, vals, context)
|
||||
|
|
|
@ -520,7 +520,7 @@ class account_invoice(osv.osv):
|
|||
'credit':x['price']<0 and -x['price'],
|
||||
'account_id':x['account_id'],
|
||||
'analytic_lines':x.get('analytic_lines', []),
|
||||
'amount_currency':x.get('amount_currency', False),
|
||||
'amount_currency':x['price']>0 and abs(x.get('amount_currency', False)) or -abs(x.get('amount_currency', False)),
|
||||
'currency_id':x.get('currency_id', False),
|
||||
'tax_code_id': x.get('tax_code_id', False),
|
||||
'tax_amount': x.get('tax_amount', False),
|
||||
|
@ -703,6 +703,7 @@ class account_invoice(osv.osv):
|
|||
'partner_id': invoice.partner_id.id,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
|
||||
lines = [(0, 0, l1), (0, 0, l2)]
|
||||
move = {'name': name, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id}
|
||||
move_id = self.pool.get('account.move').create(cr, uid, move)
|
||||
|
|
Loading…
Reference in New Issue