Fix query generation on Move Line model for issue1563

This commit is contained in:
Bertrand Chenal committed 2010-07-01 23:53:49 +02:00
1 parent 3c35539110
commit d2bdf21175
1 file changed
+5 -4
+5 -4
View File
@@ -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)