- debit = debit > 0 and amount_residual or 0.0
- credit = credit > 0 and amount_residual or 0.0
- amount_str = rml_parser.formatLang(debit or credit, currency_obj=company_currency)
- total_amount_str = rml_parser.formatLang(total_amount, currency_obj=company_currency)
- if target_currency and target_currency != company_currency:
- amount_currency_str = rml_parser.formatLang(debit or credit, currency_obj=line_currency)
- total_amount_currency_str = rml_parser.formatLang(total_amount, currency_obj=line_currency)
- ctx = context.copy()
- if target_date:
- ctx.update({'date': target_date})
- debit = currency_obj.compute(cr, uid, company_currency.id, target_currency.id, debit, context=ctx)
- credit = currency_obj.compute(cr, uid, company_currency.id, target_currency.id, credit, context=ctx)
- amount_str = rml_parser.formatLang(debit or credit, currency_obj=target_currency)
- total_amount = currency_obj.compute(cr, uid, company_currency.id, target_currency.id, total_amount, context=ctx)
- total_amount_str = rml_parser.formatLang(total_amount, currency_obj=target_currency)
-
- ret_line['credit'] = credit
- ret_line['debit'] = debit
+ total_amount = abs(debit - credit)
+ actual_debit = debit > 0 and amount or 0.0
+ actual_credit = credit > 0 and amount or 0.0
+ if line_currency != target_currency:
+ amount_currency_str = rml_parser.formatLang(actual_debit or actual_credit, currency_obj=line_currency)
+ total_amount_currency_str = rml_parser.formatLang(total_amount, currency_obj=line_currency)
+ ret_line['credit_currency'] = actual_credit
+ ret_line['debit_currency'] = actual_debit
+ ctx = context.copy()
+ if target_date:
+ ctx.update({'date': target_date})
+ total_amount = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, total_amount, context=ctx)
+ actual_debit = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, actual_debit, context=ctx)
+ actual_credit = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, actual_credit, context=ctx)
+ amount_str = rml_parser.formatLang(actual_debit or actual_credit, currency_obj=target_currency)
+ total_amount_str = rml_parser.formatLang(total_amount, currency_obj=target_currency)
+
+ ret_line['debit'] = actual_debit
+ ret_line['credit'] = actual_credit