Merge lp:~openerp-dev/openobject-addons/6.0-opw-18180-ado into lp:openobject-addons/6.0

Proposed by Amit Dodiya (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-18180-ado
Merge into: lp:openobject-addons/6.0
Diff against target: 52 lines (+18/-6)
1 file modified
account_voucher/account_voucher.py (+18/-6)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-18180-ado
Reviewer Review Type Date Requested Status
nel Pending
Naresh(OpenERP) Pending
Review via email: mp+80881@code.launchpad.net

Description of the change

Hello ,

"[FIX] Multi currency gives write-off amount while payment"

Thanks,
Amit

To post a comment you must log in.

Unmerged revisions

4904. By Amit Dodiya (OpenERP)

[FIX] Multi currency gives write-off amount while payment

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_voucher/account_voucher.py'
2--- account_voucher/account_voucher.py 2011-10-24 07:25:44 +0000
3+++ account_voucher/account_voucher.py 2011-11-01 10:07:27 +0000
4@@ -151,9 +151,9 @@
5 def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount):
6 debit = credit = 0.0
7 for l in line_dr_ids:
8- debit += l['amount']
9+ debit += l['amount_unreconciled']
10 for l in line_cr_ids:
11- credit += l['amount']
12+ credit += l['amount_unreconciled']
13 return abs(amount - abs(credit - debit))
14
15 def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount):
16@@ -477,9 +477,15 @@
17
18 company_currency = journal.company_id.currency_id.id
19 if company_currency != currency_id and ttype == 'payment':
20- total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit, context=context_multi_currency)
21+ if journal.currency.id == currency_id:
22+ total_debit = total_debit
23+ else:
24+ total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit, context=context_multi_currency)
25 elif company_currency != currency_id and ttype == 'receipt':
26- total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit, context=context_multi_currency)
27+ if journal.currency.id == currency_id:
28+ total_credit = total_credit
29+ else:
30+ total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit, context=context_multi_currency)
31
32 for line in moves:
33 if line.credit and line.reconcile_partial_id and ttype == 'receipt':
34@@ -507,11 +513,17 @@
35 }
36
37 if line.credit:
38- amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_debit), context=context_multi_currency))
39+ if journal.currency:
40+ amount = total_debit
41+ else:
42+ amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_debit), context=context_multi_currency))
43 rs['amount'] = amount
44 total_debit -= amount
45 else:
46- amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_credit), context=context_multi_currency))
47+ if journal.currency:
48+ amount = total_credit
49+ else:
50+ amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_credit), context=context_multi_currency))
51 rs['amount'] = amount
52 total_credit -= amount
53