[FIX] account: aged receivable partner balance
We need to ensure the account move lines we search for in case of partial reconciliation are within the period boundaries
Before this commit, when a partial reconciliation has been made long after others, the date used would have been this former move's
because of the MAX() function introduced by commit 3128e84243
Hence for one period, if that date were to be outside the period boundaries, the entire reconciliation would have been discarded, leaving the period due amount to 0, but a non-null total
This commit still uses the MAX() function, but specifies the aml date must be within the period boundaries
OPW 740793
OPW 725890
Closes #17098
This commit is contained in:
parent
058b9cbb10
commit
0e1b8e5e81
|
@ -151,15 +151,23 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header):
|
|||
for i in range(5):
|
||||
args_list = (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids),self.date_from,)
|
||||
dates_query = '(COALESCE(l.date_maturity,l.date)'
|
||||
date_partial = ''
|
||||
arg_partial = ()
|
||||
if form[str(i)]['start'] and form[str(i)]['stop']:
|
||||
dates_query += ' BETWEEN %s AND %s)'
|
||||
args_list += (form[str(i)]['start'], form[str(i)]['stop'])
|
||||
date_partial = 'AND l.date <= %s'
|
||||
arg_partial = (form[str(i)]['stop'],)
|
||||
elif form[str(i)]['start']:
|
||||
dates_query += ' >= %s)'
|
||||
args_list += (form[str(i)]['start'],)
|
||||
date_partial = 'AND l.date >= %s'
|
||||
arg_partial = (form[str(i)]['start'],)
|
||||
else:
|
||||
dates_query += ' <= %s)'
|
||||
args_list += (form[str(i)]['stop'],)
|
||||
date_partial = 'AND l.date <= %s'
|
||||
arg_partial = (form[str(i)]['stop'],)
|
||||
args_list += (self.date_from,)
|
||||
self.cr.execute('''SELECT l.partner_id, SUM(l.debit-l.credit), l.reconcile_partial_id
|
||||
FROM account_move_line AS l, account_account, account_move am
|
||||
|
@ -186,7 +194,8 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header):
|
|||
JOIN account_account AS a ON l.account_id = a.id
|
||||
WHERE reconcile_partial_id = %s
|
||||
AND a.type IN %s
|
||||
''', (partner_info[2], tuple(self.ACCOUNT_TYPE),))
|
||||
''' + date_partial
|
||||
, (partner_info[2], tuple(self.ACCOUNT_TYPE),) + arg_partial)
|
||||
date = self.cr.fetchall()
|
||||
# Just in case date is not defined (but it should be defined)
|
||||
if date and not date[0][0]:
|
||||
|
|
Loading…
Reference in New Issue