From d2bdf21175ec074a6f1eca1fb1afd7d859fc2674 Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Thu, 1 Jul 2010 23:53:49 +0200 Subject: [PATCH] Fix query generation on Move Line model for issue1563 --- move.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/move.py b/move.py index 758312e15a..2e3cd93c31 100644 --- a/move.py +++ b/move.py @@ -986,8 +986,9 @@ class Line(ModelSQL, ModelView): ('start_date', '<=', context['date']), ('end_date', '>=', context['date']), ], limit=1, context=context) - if not fiscalyear_ids: - fiscalyear_ids = [0] + + fiscalyear_id = fiscalyear_ids and fiscalyear_ids[0] or 0 + if context.get('posted'): return (obj + '.active ' \ 'AND ' + obj + '.state != \'draft\' ' \ @@ -996,7 +997,7 @@ class Line(ModelSQL, ModelView): 'account_period AS p ' \ 'WHERE m.period = p.id ' \ 'AND p.fiscalyear = ' + \ - str(fiscalyear_ids[0]) + ' ' \ + str(fiscalyear_id) + ' ' \ 'AND m.date <= date(\'' + \ str(context['date']) + '\') ' \ 'AND m.state = \'posted\' ' \ @@ -1009,7 +1010,7 @@ class Line(ModelSQL, ModelView): 'account_period AS p ' \ 'WHERE m.period = p.id ' \ 'AND p.fiscalyear = ' + \ - str(fiscalyear_ids[0]) + ' ' \ + str(fiscalyear_id) + ' ' \ 'AND m.date <= date(\'' + \ str(context['date']) + '\')' \ ')', fiscalyear_ids)