From 0e1b8e5e81a0eafd5cc8950e935ddcbb867a57cb Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 19 May 2017 10:57:05 +0200 Subject: [PATCH] [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 3128e8424373c545ea821c6d7e067f431f5b54d3 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 --- addons/account/report/account_aged_partner_balance.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/account/report/account_aged_partner_balance.py b/addons/account/report/account_aged_partner_balance.py index cb77e0f578c..ae21a0379ed 100644 --- a/addons/account/report/account_aged_partner_balance.py +++ b/addons/account/report/account_aged_partner_balance.py @@ -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]: