account.move.line: Fix ugly SQL call
authorP. Christeas <p_christ@hol.gr>
Tue, 16 Nov 2010 14:52:07 +0000 (16:52 +0200)
committerP. Christeas <p_christ@hol.gr>
Tue, 16 Nov 2010 14:52:07 +0000 (16:52 +0200)
A matter of coding style, tripple quotes in the same line, put in a list
is just a candidate for the hall of shame.

bzr revid: p_christ@hol.gr-20101116145207-t71p73sfzjyvsfht

addons/account/account_move_line.py

index cdb692f..3044719 100644 (file)
@@ -300,19 +300,15 @@ class account_move_line(osv.osv):
             context = {}
         c = context.copy()
         c['initital_bal'] = True
-        sql = [
-            """SELECT l2.id, SUM(l1.debit-l1.credit) FROM account_move_line l1, account_move_line l2""",
-            """WHERE l2.account_id = l1.account_id""",
-            """AND""",
-            """l1.id <= l2.id""",
-            """AND""",
-            """l2.id IN %s""",
-            """AND""",
-            self._query_get(cr, uid, obj='l1', context=c),
-            """ GROUP BY l2.id""",
-        ]
-
-        cr.execute('\n'.join(sql), [tuple(ids)])
+        sql = """SELECT l2.id, SUM(l1.debit-l1.credit) 
+                    FROM account_move_line l1, account_move_line l2
+                    WHERE l2.account_id = l1.account_id
+                      AND l1.id <= l2.id
+                      AND l2.id IN %%s AND """ + \
+                self._query_get(cr, uid, obj='l1', context=c) + \
+                " GROUP BY l2.id"
+
+        cr.execute(sql, [tuple(ids)])
         res = dict(cr.fetchall())
         return res