← Back to team overview

credativ team mailing list archive

[Merge] lp:~credativ/openobject-addons/fix-c2c-budgets-6.0 into lp:openobject-addons/extra-6.0

 

Dmitrijs Ledkovs (credativ) has proposed merging lp:~credativ/openobject-addons/fix-c2c-budgets-6.0 into lp:openobject-addons/extra-6.0.

Requested reviews:
  OpenERP Committers (openerp-commiter)
Related bugs:
  Bug #514740 in OpenERP Addons: "c2c_budget account_account_rel missing"
  https://bugs.launchpad.net/openobject-addons/+bug/514740

For more details, see:
https://code.launchpad.net/~credativ/openobject-addons/fix-c2c-budgets-6.0/+merge/81574

Forward-port of a fix from 5.0 which didn't get applied to 6.0 nor trunk.
-- 
https://code.launchpad.net/~credativ/openobject-addons/fix-c2c-budgets-6.0/+merge/81574
Your team credativ is subscribed to branch lp:~credativ/openobject-addons/fix-c2c-budgets-6.0.
=== modified file 'c2c_budget/wizard/validate_budget_structure.py'
--- c2c_budget/wizard/validate_budget_structure.py	2009-10-15 11:25:40 +0000
+++ c2c_budget/wizard/validate_budget_structure.py	2011-11-08 13:52:55 +0000
@@ -81,7 +81,7 @@
         self.cr = cr
         
         sql_filters =     self._get_sql_filters(data['form']['company'], data['form']['account_type'][0][2])
-        sql_filters_aa2 = self._get_sql_filters(data['form']['company'], data['form']['account_type'][0][2], 'aa2')
+        sql_filters_aa2 = self._get_sql_filters(data['form']['company'], data['form']['account_type'][0][2], 'aa')
         
         root_id = data['ids'][0]
         
@@ -213,10 +213,8 @@
         """ return all account that do not have parents """
         
         query = """ SELECT distinct(aa.id)
-                    FROM account_account aa LEFT OUTER JOIN account_account_rel rel ON (aa.id = rel.child_id)
-                    WHERE rel.child_id IS NULL
-                    AND aa.active
-                    %s """ % sql_filters
+                    FROM account_account aa 
+                    WHERE aa.active %s """ % sql_filters
         self.cr.execute(query)
         
         result = map(lambda x: x[0], self.cr.fetchall())
@@ -234,12 +232,8 @@
 
         #build a dictionnary {parent_id -> [children_ids]}
         children_ids =  {}
-        query = """SELECT rel.child_id, rel.parent_id
-           FROM account_account_rel rel, account_account aa, account_account aa2
-           WHERE rel.parent_id = aa.id
-           AND rel.child_id = aa2.id
-           AND aa.active 
-           AND aa2.active %s """ % (sql_filter)
+        query = """SELECT aa.id, aa.parent_id
+           FROM account_account aa WHERE aa.active %s """ % (sql_filter)    
            
         self.cr.execute(query)
         for i in self.cr.fetchall():