|
|
@ -131,20 +131,26 @@ class ReportAgedPartnerBalance(models.AbstractModel): |
|
|
|
partner_id = line.partner_id.id or False |
|
|
|
if partner_id not in undue_amounts: |
|
|
|
undue_amounts[partner_id] = 0.0 |
|
|
|
line_amount = ResCurrency._get_conversion_rate(line.company_id.currency_id, |
|
|
|
user_currency, line.balance) |
|
|
|
line_amount = ResCurrency._convert(line.balance, user_currency, |
|
|
|
line.company_id, date_from) |
|
|
|
if user_currency.is_zero(line_amount): |
|
|
|
continue |
|
|
|
for partial_line in line.matched_debit_ids: |
|
|
|
if partial_line.max_date <= date_from: |
|
|
|
line_amount += ResCurrency._get_conversion_rate( |
|
|
|
partial_line.company_id.currency_id, user_currency, |
|
|
|
partial_line.amount) |
|
|
|
line_amount += ResCurrency._convert( |
|
|
|
from_amount=partial_line.amount, |
|
|
|
to_currency=user_currency, |
|
|
|
company=partial_line.company_id, |
|
|
|
date=date_from |
|
|
|
) |
|
|
|
for partial_line in line.matched_credit_ids: |
|
|
|
if partial_line.max_date <= date_from: |
|
|
|
line_amount -= ResCurrency._get_conversion_rate( |
|
|
|
partial_line.company_id.currency_id, user_currency, |
|
|
|
partial_line.amount) |
|
|
|
line_amount -= ResCurrency._convert( |
|
|
|
from_amount=partial_line.amount, |
|
|
|
to_currency=user_currency, |
|
|
|
company=partial_line.company_id, |
|
|
|
date=date_from |
|
|
|
) |
|
|
|
if not self.env.company.currency_id.is_zero(line_amount): |
|
|
|
undue_amounts[partner_id] += line_amount |
|
|
|
lines[partner_id].append({ |
|
|
@ -159,7 +165,6 @@ class ReportAgedPartnerBalance(models.AbstractModel): |
|
|
|
args_list = ( |
|
|
|
tuple(move_state), tuple(account_type), tuple(partner_ids),) |
|
|
|
dates_query = '(COALESCE(l.date_maturity,l.date)' |
|
|
|
|
|
|
|
if periods[str(i)]['start'] and periods[str(i)]['stop']: |
|
|
|
dates_query += ' BETWEEN %s AND %s)' |
|
|
|
args_list += ( |
|
|
@ -189,21 +194,30 @@ class ReportAgedPartnerBalance(models.AbstractModel): |
|
|
|
partner_id = line.partner_id.id or False |
|
|
|
if partner_id not in partners_amount: |
|
|
|
partners_amount[partner_id] = 0.0 |
|
|
|
line_amount = ResCurrency._get_conversion_rate( |
|
|
|
line.company_id.currency_id, |
|
|
|
user_currency, line.balance) |
|
|
|
line_amount = ResCurrency._convert( |
|
|
|
from_amount=line.balance, |
|
|
|
to_currency=user_currency, |
|
|
|
company=line.company_id, |
|
|
|
date=date_from |
|
|
|
) |
|
|
|
if user_currency.is_zero(line_amount): |
|
|
|
continue |
|
|
|
for partial_line in line.matched_debit_ids: |
|
|
|
if partial_line.max_date <= date_from: |
|
|
|
line_amount += ResCurrency._get_conversion_rate( |
|
|
|
partial_line.company_id.currency_id, user_currency, |
|
|
|
partial_line.amount) |
|
|
|
line_amount += ResCurrency._convert( |
|
|
|
from_amount=partial_line.amount, |
|
|
|
to_currency=user_currency, |
|
|
|
company=partial_line.company_id, |
|
|
|
date=date_from |
|
|
|
) |
|
|
|
for partial_line in line.matched_credit_ids: |
|
|
|
if partial_line.max_date <= date_from: |
|
|
|
line_amount -= ResCurrency._get_conversion_rate( |
|
|
|
partial_line.company_id.currency_id, user_currency, |
|
|
|
partial_line.amount) |
|
|
|
line_amount -= ResCurrency._convert( |
|
|
|
from_amount=partial_line.amount, |
|
|
|
to_currency=user_currency, |
|
|
|
company=partial_line.company_id, |
|
|
|
date=date_from |
|
|
|
) |
|
|
|
if not self.env.company.currency_id.is_zero( |
|
|
|
line_amount): |
|
|
|
partners_amount[partner_id] += line_amount |
|
|
|