diff --git a/addons/account/report/account_aged_partner_balance.py b/addons/account/report/account_aged_partner_balance.py index b58c712d3a2..37b5064bf60 100644 --- a/addons/account/report/account_aged_partner_balance.py +++ b/addons/account/report/account_aged_partner_balance.py @@ -130,17 +130,28 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): # Each history will contain : history[1] = {'': } history = [] for i in range(5): + args_list = (tuple(self.ACCOUNT_TYPE), tuple(partner_ids) ,self.date_from,) + dates_query = '(COALESCE(date_maturity,date)' + 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']) + elif form[str(i)]['start']: + dates_query += ' > %s)' + args_list += (form[str(i)]['start'],) + else: + dates_query += ' < %s)' + args_list += (form[str(i)]['stop'],) self.cr.execute('SELECT partner_id, SUM(debit-credit)\ FROM account_move_line AS l, account_account\ WHERE (l.account_id = account_account.id)\ AND (account_account.type IN %s)\ - AND (COALESCE(date_maturity,date) BETWEEN %s AND %s)\ AND (partner_id IN %s)\ AND ((reconcile_id IS NULL)\ OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND '+ self.query + '\ AND account_account.active\ - GROUP BY partner_id' , (tuple(self.ACCOUNT_TYPE), form[str(i)]['start'], form[str(i)]['stop'], tuple(partner_ids) ,self.date_from,)) + AND ' + dates_query + '\ + GROUP BY partner_id' , args_list) t = self.cr.fetchall() d = {} for i in t: diff --git a/addons/account/report/account_aged_partner_balance.rml b/addons/account/report/account_aged_partner_balance.rml index bd52f9be4f5..3bc159d8288 100644 --- a/addons/account/report/account_aged_partner_balance.rml +++ b/addons/account/report/account_aged_partner_balance.rml @@ -168,7 +168,7 @@ Partners - [[ data['form']['direction_selection'] == 'future' and 'Due' or 'Not due' ]] [[ formatLang(data['form']['date1'],date=True) ]] + [[ data['form']['direction_selection'] == 'future' and 'Due' or 'Not due' ]] [[ data['form']['4']['name'] ]] diff --git a/addons/account/wizard/account_report_aged_partner_balance.py b/addons/account/wizard/account_report_aged_partner_balance.py index 29867f04d5b..fb0e404401a 100644 --- a/addons/account/wizard/account_report_aged_partner_balance.py +++ b/addons/account/wizard/account_report_aged_partner_balance.py @@ -75,18 +75,18 @@ class account_aged_trial_balance(osv.osv_memory): for i in range(5)[::-1]: stop = start - RelativeDateTime(days=period_length) res[str(i)] = { - 'name' : str((5-(i+1)) * period_length) + '-' + str((5-i) * period_length), + 'name': (i!=0 and (str((5-(i+1)) * period_length) + '-' + str((5-i) * period_length)) or ('+'+str(4 * period_length))), 'stop': start.strftime('%Y-%m-%d'), - 'start' : stop.strftime('%Y-%m-%d'), + 'start': (i!=0 and stop.strftime('%Y-%m-%d') or None), } start = stop - RelativeDateTime(days=1) else: for i in range(5): stop = start + RelativeDateTime(days=period_length) res[str(5-(i+1))] = { - 'name' : str((i) * period_length)+'-' + str((i+1) * period_length), + 'name' : (i!=4 and str((i) * period_length)+'-' + str((i+1) * period_length) or ('+'+str(4 * period_length))), 'start': start.strftime('%Y-%m-%d'), - 'stop': stop.strftime('%Y-%m-%d'), + 'stop': (i!=4 and stop.strftime('%Y-%m-%d') or None), } start = stop + RelativeDateTime(days=1) data['form'].update(res) @@ -99,4 +99,4 @@ class account_aged_trial_balance(osv.osv_memory): account_aged_trial_balance() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: