← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~therp-nl/ocb-addons/6.1_lp1237832 into lp:ocb-addons/6.1

 

Holger Brunn (Therp) has proposed merging lp:~therp-nl/ocb-addons/6.1_lp1237832 into lp:ocb-addons/6.1.

Requested reviews:
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1237832 in OpenERP Community Backports (Addons): "[6.1] [7.0] [trunk] [account_budget] doesn't recurse into analytic account's children"
  https://bugs.launchpad.net/ocb-addons/+bug/1237832

For more details, see:
https://code.launchpad.net/~therp-nl/ocb-addons/6.1_lp1237832/+merge/190312
-- 
https://code.launchpad.net/~therp-nl/ocb-addons/6.1_lp1237832/+merge/190312
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~therp-nl/ocb-addons/6.1_lp1237832 into lp:ocb-addons/6.1.
=== modified file 'account_budget/account_budget.py'
--- account_budget/account_budget.py	2013-10-09 12:24:36 +0000
+++ account_budget/account_budget.py	2013-10-10 08:53:35 +0000
@@ -126,7 +126,21 @@
             if context.has_key('wizard_date_to'):
                 date_to = context['wizard_date_to']
             if line.analytic_account_id.id:
-                cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE account_id=%s AND (date "
+                cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE account_id in "
+                       """(with recursive account_analytic_account_hierarchy(id)
+                        as 
+                            (
+                                select id from account_analytic_account 
+                                    where id=%s
+                                union all
+                                select account_analytic_account.id from 
+                                    account_analytic_account 
+                                    join account_analytic_account_hierarchy
+                                    on account_analytic_account.parent_id=
+                                        account_analytic_account_hierarchy.id
+                            )"""
+                       "select id from account_analytic_account_hierarchy) "
+                       "AND (date "
                        "between to_date(%s,'yyyy-mm-dd') AND to_date(%s,'yyyy-mm-dd')) AND "
                        "general_account_id=ANY(%s)", (line.analytic_account_id.id, date_from, date_to,acc_ids,))
                 result = cr.fetchone()[0]


Follow ups