Please review this at http://codereview.appspot.com/3742043/

Affected files:
  M trytond/model/modelsql.py


Index: trytond/model/modelsql.py
===================================================================
--- a/trytond/model/modelsql.py
+++ b/trytond/model/modelsql.py
@@ -1864,6 +1864,7 @@
                             tables_args[tables[i]] = args
                     if table_join not in tables:
                         tables.insert(0, table_join)
+                        tables_args[table_join] = []

                     table_join2 = 'LEFT JOIN "' + table_name2 + '" AS ' \
                             '"' + table_name2 + '.' + link_field2 +
'" ON ' \
@@ -1874,7 +1875,7 @@
                         if table_name2 in order_by[i]:
                             order_by[i] = order_by[i].replace(table_name2,
                                     table_name2 + '.' + link_field2)
-                    for i in range(len(tables)):
+                    for i in range(1, len(tables)):
                         if table_name2 in tables[i]:
                             args = tables_args[tables[i]]
                             del tables_args[tables[i]]
@@ -1883,6 +1884,7 @@
                             tables_args[tables[i]] = args
                     if table_join2 not in tables:
                         tables.insert(1, table_join2)
+                        tables_args[table_join2] = []
                     return order_by, tables, tables_args

             if field_name in self._columns \



-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/

Attachment: pgpHgLzjnORaA.pgp
Description: PGP signature

Reply via email to